@react-native-ohos/react-native-mmkv 3.3.1-1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (1115) hide show
  1. package/MMKV/Core/CMakeLists.txt +172 -0
  2. package/MMKV/Core/CodedInputData.cpp +252 -0
  3. package/MMKV/Core/CodedInputData.h +87 -0
  4. package/MMKV/Core/CodedInputDataCrypt.cpp +280 -0
  5. package/MMKV/Core/CodedInputDataCrypt.h +87 -0
  6. package/MMKV/Core/CodedInputDataCrypt_OSX.cpp +62 -0
  7. package/MMKV/Core/CodedInputData_OSX.cpp +92 -0
  8. package/MMKV/Core/CodedOutputData.cpp +186 -0
  9. package/MMKV/Core/CodedOutputData.h +88 -0
  10. package/MMKV/Core/Core.xcodeproj/project.pbxproj +707 -0
  11. package/MMKV/Core/Core.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  12. package/MMKV/Core/Core.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  13. package/MMKV/Core/Core.xcodeproj/xcshareddata/xcschemes/Core.xcscheme +67 -0
  14. package/MMKV/Core/Core.xcodeproj/xcshareddata/xcschemes/MMKVWatchCore.xcscheme +67 -0
  15. package/MMKV/Core/InterProcessLock.cpp +186 -0
  16. package/MMKV/Core/InterProcessLock.h +119 -0
  17. package/MMKV/Core/InterProcessLock_Android.cpp +103 -0
  18. package/MMKV/Core/InterProcessLock_Win32.cpp +108 -0
  19. package/MMKV/Core/KeyValueHolder.cpp +236 -0
  20. package/MMKV/Core/KeyValueHolder.h +122 -0
  21. package/MMKV/Core/MMBuffer.cpp +210 -0
  22. package/MMKV/Core/MMBuffer.h +111 -0
  23. package/MMKV/Core/MMKV.cpp +1702 -0
  24. package/MMKV/Core/MMKV.h +595 -0
  25. package/MMKV/Core/MMKVLog.cpp +127 -0
  26. package/MMKV/Core/MMKVLog.h +86 -0
  27. package/MMKV/Core/MMKVLog_Android.cpp +134 -0
  28. package/MMKV/Core/MMKVMetaInfo.hpp +99 -0
  29. package/MMKV/Core/MMKVPredef.h +293 -0
  30. package/MMKV/Core/MMKV_Android.cpp +261 -0
  31. package/MMKV/Core/MMKV_IO.cpp +1905 -0
  32. package/MMKV/Core/MMKV_IO.h +57 -0
  33. package/MMKV/Core/MMKV_OSX.cpp +423 -0
  34. package/MMKV/Core/MMKV_OSX.h +57 -0
  35. package/MMKV/Core/MemoryFile.cpp +603 -0
  36. package/MMKV/Core/MemoryFile.h +194 -0
  37. package/MMKV/Core/MemoryFile_Android.cpp +236 -0
  38. package/MMKV/Core/MemoryFile_Linux.cpp +125 -0
  39. package/MMKV/Core/MemoryFile_OSX.cpp +142 -0
  40. package/MMKV/Core/MemoryFile_Win32.cpp +554 -0
  41. package/MMKV/Core/MiniPBCoder.cpp +672 -0
  42. package/MMKV/Core/MiniPBCoder.h +151 -0
  43. package/MMKV/Core/MiniPBCoder_OSX.cpp +237 -0
  44. package/MMKV/Core/PBEncodeItem.hpp +104 -0
  45. package/MMKV/Core/PBUtility.cpp +61 -0
  46. package/MMKV/Core/PBUtility.h +148 -0
  47. package/MMKV/Core/ScopedLock.hpp +69 -0
  48. package/MMKV/Core/ThreadLock.cpp +75 -0
  49. package/MMKV/Core/ThreadLock.h +81 -0
  50. package/MMKV/Core/ThreadLock_Win32.cpp +89 -0
  51. package/MMKV/Core/aes/AESCrypt.cpp +273 -0
  52. package/MMKV/Core/aes/AESCrypt.h +112 -0
  53. package/MMKV/Core/aes/openssl/openssl_aes-armv4.S +1243 -0
  54. package/MMKV/Core/aes/openssl/openssl_aes.h +130 -0
  55. package/MMKV/Core/aes/openssl/openssl_aes_core.cpp +1044 -0
  56. package/MMKV/Core/aes/openssl/openssl_aes_locl.h +38 -0
  57. package/MMKV/Core/aes/openssl/openssl_aesv8-armx.S +308 -0
  58. package/MMKV/Core/aes/openssl/openssl_arm_arch.h +84 -0
  59. package/MMKV/Core/aes/openssl/openssl_cfb128.cpp +97 -0
  60. package/MMKV/Core/aes/openssl/openssl_md32_common.h +254 -0
  61. package/MMKV/Core/aes/openssl/openssl_md5.h +49 -0
  62. package/MMKV/Core/aes/openssl/openssl_md5_dgst.cpp +166 -0
  63. package/MMKV/Core/aes/openssl/openssl_md5_locl.h +75 -0
  64. package/MMKV/Core/aes/openssl/openssl_md5_one.cpp +30 -0
  65. package/MMKV/Core/aes/openssl/openssl_opensslconf.h +271 -0
  66. package/MMKV/Core/core.vcxproj +288 -0
  67. package/MMKV/Core/core.vcxproj.filters +150 -0
  68. package/MMKV/Core/crc32/Checksum.h +75 -0
  69. package/MMKV/Core/crc32/crc32_armv8.cpp +134 -0
  70. package/MMKV/Core/crc32/zlib/CMakeLists.txt +60 -0
  71. package/MMKV/Core/crc32/zlib/crc32.cpp +55 -0
  72. package/MMKV/Core/crc32/zlib/crc32.h +48 -0
  73. package/MMKV/Core/crc32/zlib/zconf.h +380 -0
  74. package/MMKV/Core/crc32/zlib/zutil.h +25 -0
  75. package/MMKV/LICENSE.TXT +193 -0
  76. package/MMKV/README.md +354 -0
  77. package/README.md +5 -0
  78. package/cpp/MMKVManagedBuffer.h +32 -0
  79. package/cpp/MmkvHostObject.cpp +355 -0
  80. package/cpp/MmkvHostObject.h +32 -0
  81. package/cpp/MmkvLogger.h +35 -0
  82. package/cpp/NativeMmkvModule.cpp +43 -0
  83. package/cpp/NativeMmkvModule.h +38 -0
  84. package/harmony/reactNativeMMKV/BuildProfile.ets +17 -0
  85. package/harmony/reactNativeMMKV/LICENSE +20 -0
  86. package/harmony/reactNativeMMKV/NOTICE +34 -0
  87. package/harmony/reactNativeMMKV/README.OpenSource +11 -0
  88. package/harmony/reactNativeMMKV/build-profile.json5 +9 -0
  89. package/harmony/reactNativeMMKV/hvigorfile.ts +6 -0
  90. package/harmony/reactNativeMMKV/index.ets +24 -0
  91. package/harmony/reactNativeMMKV/oh-package.json5 +15 -0
  92. package/harmony/reactNativeMMKV/src/main/cpp/CMakeLists.txt +15 -0
  93. package/harmony/reactNativeMMKV/src/main/cpp/ComponentDescriptors.h +39 -0
  94. package/harmony/reactNativeMMKV/src/main/cpp/EventEmitters.cpp +41 -0
  95. package/harmony/reactNativeMMKV/src/main/cpp/EventEmitters.h +182 -0
  96. package/harmony/reactNativeMMKV/src/main/cpp/HarmonyLogger.cpp +32 -0
  97. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/.clang-format +36 -0
  98. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/.dockerignore +2 -0
  99. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/.github/FUNDING.yml +14 -0
  100. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/.github/ISSUE_TEMPLATE/bug_report.md +45 -0
  101. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/.gitmodules +3 -0
  102. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Android/MMKV/build.gradle +54 -0
  103. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Android/MMKV/checkstyle.xml +156 -0
  104. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Android/MMKV/debug.keystore +0 -0
  105. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Android/MMKV/gradle/android-publish-private.gradle +207 -0
  106. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Android/MMKV/gradle/android-publish.gradle +276 -0
  107. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Android/MMKV/gradle/build_library.gradle +62 -0
  108. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Android/MMKV/gradle/check.gradle +76 -0
  109. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Android/MMKV/gradle/wrapper/gradle-wrapper.jar +0 -0
  110. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Android/MMKV/gradle/wrapper/gradle-wrapper.properties +6 -0
  111. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Android/MMKV/gradle.properties +25 -0
  112. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Android/MMKV/gradlew +172 -0
  113. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Android/MMKV/gradlew.bat +84 -0
  114. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Android/MMKV/mmkv/CMakeLists.txt +56 -0
  115. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Android/MMKV/mmkv/build.gradle +238 -0
  116. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Android/MMKV/mmkv/gradle.properties +2 -0
  117. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Android/MMKV/mmkv/proguard-rules.pro +9 -0
  118. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Android/MMKV/mmkv/src/androidTest/AndroidManifest.xml +11 -0
  119. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Android/MMKV/mmkv/src/androidTest/java/com/tencent/mmkv/MMKVTest.java +270 -0
  120. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Android/MMKV/mmkv/src/androidTest/java/com/tencent/mmkv/MMKVTestService.java +79 -0
  121. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Android/MMKV/mmkv/src/main/AndroidManifest.xml +3 -0
  122. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Android/MMKV/mmkv/src/main/aidl/com/tencent/mmkv/ParcelableMMKV.aidl +4 -0
  123. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Android/MMKV/mmkv/src/main/cpp/flutter-bridge.cpp +706 -0
  124. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Android/MMKV/mmkv/src/main/cpp/native-bridge.cpp +1244 -0
  125. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Android/MMKV/mmkv/src/main/java/com/tencent/mmkv/MMKV.java +2024 -0
  126. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Android/MMKV/mmkv/src/main/java/com/tencent/mmkv/MMKVContentChangeNotification.java +34 -0
  127. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Android/MMKV/mmkv/src/main/java/com/tencent/mmkv/MMKVContentProvider.java +174 -0
  128. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Android/MMKV/mmkv/src/main/java/com/tencent/mmkv/MMKVHandler.java +63 -0
  129. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Android/MMKV/mmkv/src/main/java/com/tencent/mmkv/MMKVLogLevel.java +52 -0
  130. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Android/MMKV/mmkv/src/main/java/com/tencent/mmkv/MMKVProcessUtil.java +100 -0
  131. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Android/MMKV/mmkv/src/main/java/com/tencent/mmkv/MMKVRecoverStrategic.java +36 -0
  132. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Android/MMKV/mmkv/src/main/java/com/tencent/mmkv/NameSpace.java +214 -0
  133. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Android/MMKV/mmkv/src/main/java/com/tencent/mmkv/NativeBuffer.java +36 -0
  134. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Android/MMKV/mmkv/src/main/java/com/tencent/mmkv/ParcelableMMKV.java +108 -0
  135. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Android/MMKV/mmkv/src/main/java/com/tencent/mmkv/UnsupportedArchitectureException.java +27 -0
  136. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Android/MMKV/mmkvannotation/build.gradle +34 -0
  137. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Android/MMKV/mmkvannotation/src/main/AndroidManifest.xml +3 -0
  138. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Android/MMKV/mmkvannotation/src/main/java/dalvik/annotation/optimization/FastNative.java +104 -0
  139. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Android/MMKV/mmkvdemo/build.gradle +116 -0
  140. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Android/MMKV/mmkvdemo/proguard-rules.pro +24 -0
  141. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Android/MMKV/mmkvdemo/src/main/AndroidManifest.xml +54 -0
  142. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Android/MMKV/mmkvdemo/src/main/aidl/com/tencent/mmkvdemo/IAshmemMMKV.aidl +8 -0
  143. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Android/MMKV/mmkvdemo/src/main/cpp/CMakeLists.txt +50 -0
  144. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Android/MMKV/mmkvdemo/src/main/cpp/mmkvdemo.cpp +245 -0
  145. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Android/MMKV/mmkvdemo/src/main/java/com/tencent/mmkvdemo/Baseline.java +297 -0
  146. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Android/MMKV/mmkvdemo/src/main/java/com/tencent/mmkvdemo/BenchMarkBaseService.java +363 -0
  147. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Android/MMKV/mmkvdemo/src/main/java/com/tencent/mmkvdemo/FakeInfo.java +67 -0
  148. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Android/MMKV/mmkvdemo/src/main/java/com/tencent/mmkvdemo/Info.java +69 -0
  149. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Android/MMKV/mmkvdemo/src/main/java/com/tencent/mmkvdemo/MainActivity.java +1029 -0
  150. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Android/MMKV/mmkvdemo/src/main/java/com/tencent/mmkvdemo/MultiProcessSharedPreferences.java +710 -0
  151. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Android/MMKV/mmkvdemo/src/main/java/com/tencent/mmkvdemo/MyApplication.java +130 -0
  152. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Android/MMKV/mmkvdemo/src/main/java/com/tencent/mmkvdemo/MyService.java +105 -0
  153. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Android/MMKV/mmkvdemo/src/main/java/com/tencent/mmkvdemo/MyService_1.java +92 -0
  154. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Android/MMKV/mmkvdemo/src/main/java/com/tencent/mmkvdemo/SQLiteKV.java +143 -0
  155. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Android/MMKV/mmkvdemo/src/main/java/com/tencent/mmkvdemo/TestParcelable.java +70 -0
  156. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Android/MMKV/mmkvdemo/src/main/kotlin/KotlinUsecase.kt +67 -0
  157. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Android/MMKV/mmkvdemo/src/main/res/drawable/ic_launcher_background.xml +170 -0
  158. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Android/MMKV/mmkvdemo/src/main/res/drawable-v24/ic_launcher_foreground.xml +34 -0
  159. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Android/MMKV/mmkvdemo/src/main/res/layout/activity_main.xml +76 -0
  160. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Android/MMKV/mmkvdemo/src/main/res/mipmap-anydpi-v26/ic_launcher.xml +5 -0
  161. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Android/MMKV/mmkvdemo/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml +5 -0
  162. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Android/MMKV/mmkvdemo/src/main/res/mipmap-hdpi/ic_launcher.png +0 -0
  163. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Android/MMKV/mmkvdemo/src/main/res/mipmap-hdpi/ic_launcher_round.png +0 -0
  164. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Android/MMKV/mmkvdemo/src/main/res/mipmap-mdpi/ic_launcher.png +0 -0
  165. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Android/MMKV/mmkvdemo/src/main/res/mipmap-mdpi/ic_launcher_round.png +0 -0
  166. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Android/MMKV/mmkvdemo/src/main/res/mipmap-xhdpi/ic_launcher.png +0 -0
  167. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Android/MMKV/mmkvdemo/src/main/res/mipmap-xhdpi/ic_launcher_round.png +0 -0
  168. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Android/MMKV/mmkvdemo/src/main/res/mipmap-xxhdpi/ic_launcher.png +0 -0
  169. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Android/MMKV/mmkvdemo/src/main/res/mipmap-xxhdpi/ic_launcher_round.png +0 -0
  170. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Android/MMKV/mmkvdemo/src/main/res/mipmap-xxxhdpi/ic_launcher.png +0 -0
  171. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Android/MMKV/mmkvdemo/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png +0 -0
  172. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Android/MMKV/mmkvdemo/src/main/res/values/colors.xml +6 -0
  173. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Android/MMKV/mmkvdemo/src/main/res/values/strings.xml +3 -0
  174. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Android/MMKV/mmkvdemo/src/main/res/values/styles.xml +11 -0
  175. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Android/MMKV/pmd-ruleset.xml +44 -0
  176. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Android/MMKV/proguard-rules/proguard-rules-android-lib.pro +54 -0
  177. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Android/MMKV/proguard-rules/proguard-rules-test.pro +6 -0
  178. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Android/MMKV/settings.gradle +3 -0
  179. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/CHANGELOG.md +979 -0
  180. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/CODE_OF_CONDUCT.md +76 -0
  181. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/CONTRIBUTING.md +61 -0
  182. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Core/CMakeLists.txt +207 -0
  183. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Core/CodedInputData.cpp +248 -0
  184. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Core/CodedInputData.h +86 -0
  185. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Core/CodedInputDataCrypt.cpp +276 -0
  186. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Core/CodedInputDataCrypt.h +86 -0
  187. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Core/CodedInputDataCrypt_OSX.cpp +62 -0
  188. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Core/CodedInputData_OSX.cpp +92 -0
  189. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Core/CodedOutputData.cpp +182 -0
  190. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Core/CodedOutputData.h +86 -0
  191. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Core/Core.xcodeproj/project.pbxproj +703 -0
  192. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Core/Core.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  193. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Core/Core.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  194. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Core/Core.xcodeproj/xcshareddata/xcschemes/Core.xcscheme +67 -0
  195. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Core/Core.xcodeproj/xcshareddata/xcschemes/MMKVWatchCore.xcscheme +67 -0
  196. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Core/InterProcessLock.cpp +211 -0
  197. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Core/InterProcessLock.h +124 -0
  198. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Core/InterProcessLock_Android.cpp +104 -0
  199. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Core/InterProcessLock_Win32.cpp +108 -0
  200. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Core/KeyValueHolder.cpp +237 -0
  201. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Core/KeyValueHolder.h +122 -0
  202. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Core/MMBuffer.cpp +207 -0
  203. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Core/MMBuffer.h +119 -0
  204. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Core/MMKV.cpp +1791 -0
  205. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Core/MMKV.h +781 -0
  206. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Core/MMKVLog.cpp +127 -0
  207. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Core/MMKVLog.h +86 -0
  208. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Core/MMKVLog_Android.cpp +134 -0
  209. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Core/MMKVMetaInfo.hpp +99 -0
  210. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Core/MMKVPredef.h +310 -0
  211. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Core/MMKV_Android.cpp +365 -0
  212. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Core/MMKV_IO.cpp +2049 -0
  213. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Core/MMKV_IO.h +85 -0
  214. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Core/MMKV_OSX.cpp +589 -0
  215. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Core/MMKV_OSX.h +30 -0
  216. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Core/MemoryFile.cpp +716 -0
  217. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Core/MemoryFile.h +212 -0
  218. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Core/MemoryFile_Android.cpp +247 -0
  219. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Core/MemoryFile_Linux.cpp +126 -0
  220. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Core/MemoryFile_OSX.cpp +173 -0
  221. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Core/MemoryFile_Win32.cpp +655 -0
  222. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Core/MiniPBCoder.cpp +668 -0
  223. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Core/MiniPBCoder.h +150 -0
  224. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Core/MiniPBCoder_OSX.cpp +237 -0
  225. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Core/PBEncodeItem.hpp +102 -0
  226. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Core/PBUtility.cpp +61 -0
  227. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Core/PBUtility.h +148 -0
  228. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Core/ScopedLock.hpp +69 -0
  229. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Core/ThreadLock.cpp +75 -0
  230. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Core/ThreadLock.h +81 -0
  231. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Core/ThreadLock_Win32.cpp +89 -0
  232. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Core/aes/AESCrypt.cpp +293 -0
  233. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Core/aes/AESCrypt.h +117 -0
  234. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Core/aes/openssl/openssl_aes.h +98 -0
  235. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Core/aes/openssl/openssl_aes_core.cpp +1044 -0
  236. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Core/aes/openssl/openssl_aes_locl.h +38 -0
  237. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Core/aes/openssl/openssl_aesv8-armx.S +308 -0
  238. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Core/aes/openssl/openssl_arm_arch.h +84 -0
  239. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Core/aes/openssl/openssl_cfb128.cpp +97 -0
  240. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Core/aes/openssl/openssl_md32_common.h +254 -0
  241. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Core/aes/openssl/openssl_md5.h +49 -0
  242. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Core/aes/openssl/openssl_md5_dgst.cpp +166 -0
  243. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Core/aes/openssl/openssl_md5_locl.h +75 -0
  244. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Core/aes/openssl/openssl_md5_one.cpp +30 -0
  245. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Core/aes/openssl/openssl_opensslconf.h +271 -0
  246. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Core/core.vcxproj +288 -0
  247. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Core/core.vcxproj.filters +150 -0
  248. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Core/crc32/CMakeLists.txt +60 -0
  249. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Core/crc32/Checksum.h +76 -0
  250. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Core/crc32/crc32_armv8.cpp +134 -0
  251. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Core/crc32/zlib/crc32.cpp +55 -0
  252. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Core/crc32/zlib/crc32.h +48 -0
  253. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Core/crc32/zlib/zconf.h +380 -0
  254. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Core/crc32/zlib/zutil.h +25 -0
  255. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Dockerfile +25 -0
  256. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/LICENSE.TXT +193 -0
  257. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/MMKV.podspec +40 -0
  258. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/MMKV.xcworkspace/contents.xcworkspacedata +10 -0
  259. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/MMKV.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  260. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/MMKVAppExtension.podspec +37 -0
  261. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/MMKVCore.podspec +47 -0
  262. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/MMKVWatchExtension.podspec +38 -0
  263. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Makefile +10 -0
  264. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/OpenHarmony/AppScope/app.json5 +10 -0
  265. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/OpenHarmony/AppScope/resources/base/element/string.json +8 -0
  266. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/OpenHarmony/AppScope/resources/base/media/app_icon.png +0 -0
  267. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/OpenHarmony/MMKV/BuildProfile.ets +17 -0
  268. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/OpenHarmony/MMKV/CHANGELOG.md +75 -0
  269. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/OpenHarmony/MMKV/Index.ets +4 -0
  270. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/OpenHarmony/MMKV/LICENSE +193 -0
  271. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/OpenHarmony/MMKV/README.md +208 -0
  272. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/OpenHarmony/MMKV/build-profile.json5 +40 -0
  273. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/OpenHarmony/MMKV/consumer-rules.txt +61 -0
  274. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/OpenHarmony/MMKV/example/Index.ets +686 -0
  275. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/OpenHarmony/MMKV/example/Util.ets +31 -0
  276. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/OpenHarmony/MMKV/hvigorfile.ts +6 -0
  277. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/OpenHarmony/MMKV/obfuscation-rules.txt +18 -0
  278. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/OpenHarmony/MMKV/oh-package.json5 +22 -0
  279. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/OpenHarmony/MMKV/src/main/cpp/CMakeLists.txt +43 -0
  280. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/OpenHarmony/MMKV/src/main/cpp/flutter-bridge.cpp +703 -0
  281. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/OpenHarmony/MMKV/src/main/cpp/native_bridge.cpp +1840 -0
  282. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/OpenHarmony/MMKV/src/main/cpp/types/libmmkv/index.d.ts +80 -0
  283. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/OpenHarmony/MMKV/src/main/cpp/types/libmmkv/oh-package.json5 +6 -0
  284. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/OpenHarmony/MMKV/src/main/ets/utils/MMKV.ets +1073 -0
  285. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/OpenHarmony/MMKV/src/main/ets/utils/MMKVHandler.ets +111 -0
  286. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/OpenHarmony/MMKV/src/main/ets/utils/MMKVLogLevel.ets +50 -0
  287. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/OpenHarmony/MMKV/src/main/ets/utils/NativeBuffer.ets +34 -0
  288. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/OpenHarmony/MMKV/src/main/ets/utils/Util.ts +24 -0
  289. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/OpenHarmony/MMKV/src/main/module.json5 +12 -0
  290. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/OpenHarmony/build-profile.json5 +62 -0
  291. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/OpenHarmony/dependencies/hvigor-4.3.0.tgz +0 -0
  292. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/OpenHarmony/dependencies/hvigor-ohos-plugin-4.3.0.tgz +0 -0
  293. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/OpenHarmony/entry/build-profile.json5 +39 -0
  294. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/OpenHarmony/entry/hvigorfile.ts +6 -0
  295. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/OpenHarmony/entry/obfuscation-rules.txt +25 -0
  296. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/OpenHarmony/entry/oh-package.json5 +13 -0
  297. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/OpenHarmony/entry/src/main/cpp/CMakeLists.txt +54 -0
  298. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/OpenHarmony/entry/src/main/cpp/napi_init.cpp +233 -0
  299. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/OpenHarmony/entry/src/main/cpp/types/libentry/index.d.ts +1 -0
  300. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/OpenHarmony/entry/src/main/cpp/types/libentry/oh-package.json5 +6 -0
  301. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/OpenHarmony/entry/src/main/ets/Util/Baseline.ets +188 -0
  302. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/OpenHarmony/entry/src/main/ets/Util/MyMMKVHandler.ets +76 -0
  303. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/OpenHarmony/entry/src/main/ets/Util/Util.ets +220 -0
  304. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/OpenHarmony/entry/src/main/ets/entryability/EntryAbility.ets +107 -0
  305. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/OpenHarmony/entry/src/main/ets/pages/Index.ets +766 -0
  306. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/OpenHarmony/entry/src/main/ets/process/DemoProcess.ets +31 -0
  307. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/OpenHarmony/entry/src/main/module.json5 +38 -0
  308. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/OpenHarmony/entry/src/main/resources/base/element/color.json +8 -0
  309. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/OpenHarmony/entry/src/main/resources/base/element/string.json +16 -0
  310. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/OpenHarmony/entry/src/main/resources/base/media/background.png +0 -0
  311. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/OpenHarmony/entry/src/main/resources/base/media/foreground.png +0 -0
  312. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/OpenHarmony/entry/src/main/resources/base/media/layered_image.json +7 -0
  313. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/OpenHarmony/entry/src/main/resources/base/media/startIcon.png +0 -0
  314. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/OpenHarmony/entry/src/main/resources/base/profile/main_pages.json +5 -0
  315. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/OpenHarmony/entry/src/main/resources/en_US/element/string.json +16 -0
  316. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/OpenHarmony/entry/src/main/resources/zh_CN/element/string.json +16 -0
  317. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/OpenHarmony/entry/src/mock/mock-config.json5 +2 -0
  318. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/OpenHarmony/entry/src/ohosTest/ets/test/Ability.test.ets +55 -0
  319. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/OpenHarmony/entry/src/ohosTest/ets/test/List.test.ets +25 -0
  320. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/OpenHarmony/entry/src/ohosTest/ets/testability/TestAbility.ets +67 -0
  321. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/OpenHarmony/entry/src/ohosTest/ets/testability/pages/Index.ets +37 -0
  322. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/OpenHarmony/entry/src/ohosTest/ets/testrunner/OpenHarmonyTestRunner.ets +110 -0
  323. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/OpenHarmony/entry/src/ohosTest/module.json5 +38 -0
  324. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/OpenHarmony/entry/src/ohosTest/resources/base/element/color.json +8 -0
  325. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/OpenHarmony/entry/src/ohosTest/resources/base/element/string.json +16 -0
  326. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/OpenHarmony/entry/src/ohosTest/resources/base/media/icon.png +0 -0
  327. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/OpenHarmony/entry/src/ohosTest/resources/base/profile/test_pages.json +5 -0
  328. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/OpenHarmony/entry/src/test/List.test.ets +25 -0
  329. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/OpenHarmony/entry/src/test/LocalUnit.test.ets +53 -0
  330. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/OpenHarmony/hvigor/hvigor-config.json5 +21 -0
  331. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/OpenHarmony/hvigorfile.ts +6 -0
  332. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/OpenHarmony/oh-package.json5 +15 -0
  333. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/POSIX/CMakeLists.txt +27 -0
  334. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/POSIX/demo/CMakeLists.txt +65 -0
  335. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/POSIX/demo/TestInterProcessLock.cpp +130 -0
  336. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/POSIX/demo/UnitTest.cpp +272 -0
  337. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/POSIX/demo/demo.cpp +1431 -0
  338. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/POSIX/demo/process.cpp +78 -0
  339. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/POSIX/golang/CMakeLists.txt +87 -0
  340. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/POSIX/golang/callback.go +121 -0
  341. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/POSIX/golang/go.mod +3 -0
  342. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/POSIX/golang/golang-bridge.cpp +731 -0
  343. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/POSIX/golang/golang-bridge.h +131 -0
  344. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/POSIX/golang/mmkv.go +817 -0
  345. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/POSIX/golang/mmkv_test.go +33 -0
  346. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/POSIX/golang/test/go.mod +7 -0
  347. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/POSIX/golang/test/main.go +455 -0
  348. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/POSIX/src/CMakeLists.txt +83 -0
  349. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/POSIX/src/libmmkv.cpp +21 -0
  350. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/CMakeLists.txt +62 -0
  351. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/README.md +6 -0
  352. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/demo.py +368 -0
  353. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/libmmkv_python.cpp +454 -0
  354. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/.appveyor.yml +35 -0
  355. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/.clang-format +38 -0
  356. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/.clang-tidy +77 -0
  357. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/.cmake-format.yaml +73 -0
  358. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/.codespell-ignore-lines +24 -0
  359. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/.gitattributes +1 -0
  360. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/.github/CODEOWNERS +9 -0
  361. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/.github/CONTRIBUTING.md +388 -0
  362. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/.github/ISSUE_TEMPLATE/bug-report.yml +61 -0
  363. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/.github/ISSUE_TEMPLATE/config.yml +8 -0
  364. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/.github/dependabot.yml +15 -0
  365. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/.github/labeler.yml +13 -0
  366. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/.github/labeler_merged.yml +8 -0
  367. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/.github/matchers/pylint.json +32 -0
  368. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/.github/pull_request_template.md +19 -0
  369. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/.github/workflows/ci.yml +1233 -0
  370. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/.github/workflows/configure.yml +92 -0
  371. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/.github/workflows/format.yml +60 -0
  372. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/.github/workflows/labeler.yml +25 -0
  373. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/.github/workflows/pip.yml +117 -0
  374. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/.github/workflows/upstream.yml +116 -0
  375. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/.pre-commit-config.yaml +156 -0
  376. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/.readthedocs.yml +20 -0
  377. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/CMakeLists.txt +375 -0
  378. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/LICENSE +29 -0
  379. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/MANIFEST.in +6 -0
  380. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/README.rst +181 -0
  381. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/SECURITY.md +13 -0
  382. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/docs/Doxyfile +21 -0
  383. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/docs/_static/css/custom.css +3 -0
  384. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/docs/advanced/cast/chrono.rst +81 -0
  385. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/docs/advanced/cast/custom.rst +93 -0
  386. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/docs/advanced/cast/eigen.rst +310 -0
  387. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/docs/advanced/cast/functional.rst +109 -0
  388. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/docs/advanced/cast/index.rst +43 -0
  389. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/docs/advanced/cast/overview.rst +170 -0
  390. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/docs/advanced/cast/stl.rst +249 -0
  391. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/docs/advanced/cast/strings.rst +296 -0
  392. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/docs/advanced/classes.rst +1335 -0
  393. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/docs/advanced/embedding.rst +262 -0
  394. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/docs/advanced/exceptions.rst +401 -0
  395. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/docs/advanced/functions.rst +614 -0
  396. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/docs/advanced/misc.rst +429 -0
  397. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/docs/advanced/pycpp/index.rst +13 -0
  398. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/docs/advanced/pycpp/numpy.rst +453 -0
  399. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/docs/advanced/pycpp/object.rst +286 -0
  400. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/docs/advanced/pycpp/utilities.rst +155 -0
  401. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/docs/advanced/smart_ptrs.rst +174 -0
  402. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/docs/basics.rst +307 -0
  403. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/docs/benchmark.py +89 -0
  404. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/docs/benchmark.rst +95 -0
  405. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/docs/changelog.rst +3121 -0
  406. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/docs/classes.rst +555 -0
  407. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/docs/cmake/index.rst +8 -0
  408. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/docs/compiling.rst +726 -0
  409. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/docs/conf.py +369 -0
  410. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/docs/faq.rst +308 -0
  411. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/docs/index.rst +48 -0
  412. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/docs/installing.rst +105 -0
  413. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/docs/limitations.rst +72 -0
  414. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/docs/pybind11-logo.png +0 -0
  415. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/docs/pybind11_vs_boost_python1.png +0 -0
  416. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/docs/pybind11_vs_boost_python1.svg +427 -0
  417. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/docs/pybind11_vs_boost_python2.png +0 -0
  418. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/docs/pybind11_vs_boost_python2.svg +427 -0
  419. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/docs/reference.rst +130 -0
  420. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/docs/release.rst +143 -0
  421. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/docs/requirements.in +6 -0
  422. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/docs/requirements.txt +275 -0
  423. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/docs/upgrade.rst +594 -0
  424. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/include/pybind11/attr.h +690 -0
  425. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/include/pybind11/buffer_info.h +208 -0
  426. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/include/pybind11/cast.h +1848 -0
  427. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/include/pybind11/chrono.h +225 -0
  428. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/include/pybind11/common.h +2 -0
  429. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/include/pybind11/complex.h +74 -0
  430. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/include/pybind11/detail/class.h +754 -0
  431. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/include/pybind11/detail/common.h +1268 -0
  432. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/include/pybind11/detail/descr.h +172 -0
  433. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/include/pybind11/detail/init.h +434 -0
  434. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/include/pybind11/detail/internals.h +749 -0
  435. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/include/pybind11/detail/type_caster_base.h +1214 -0
  436. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/include/pybind11/detail/typeid.h +65 -0
  437. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/include/pybind11/eigen/common.h +9 -0
  438. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/include/pybind11/eigen/matrix.h +714 -0
  439. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/include/pybind11/eigen/tensor.h +517 -0
  440. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/include/pybind11/eigen.h +12 -0
  441. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/include/pybind11/embed.h +313 -0
  442. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/include/pybind11/eval.h +156 -0
  443. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/include/pybind11/functional.h +138 -0
  444. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/include/pybind11/gil.h +219 -0
  445. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/include/pybind11/gil_safe_call_once.h +91 -0
  446. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/include/pybind11/iostream.h +265 -0
  447. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/include/pybind11/numpy.h +2135 -0
  448. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/include/pybind11/operators.h +202 -0
  449. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/include/pybind11/options.h +92 -0
  450. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/include/pybind11/pybind11.h +3026 -0
  451. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/include/pybind11/pytypes.h +2604 -0
  452. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/include/pybind11/stl/filesystem.h +115 -0
  453. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/include/pybind11/stl.h +448 -0
  454. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/include/pybind11/stl_bind.h +822 -0
  455. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/include/pybind11/type_caster_pyobject_ptr.h +61 -0
  456. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/include/pybind11/typing.h +239 -0
  457. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/noxfile.py +107 -0
  458. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/pybind11/__init__.py +19 -0
  459. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/pybind11/__main__.py +63 -0
  460. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/pybind11/_version.py +12 -0
  461. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/pybind11/commands.py +39 -0
  462. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/pybind11/py.typed +0 -0
  463. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/pybind11/setup_helpers.py +500 -0
  464. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/pyproject.toml +87 -0
  465. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/setup.cfg +43 -0
  466. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/setup.py +149 -0
  467. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/CMakeLists.txt +589 -0
  468. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/conftest.py +224 -0
  469. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/constructor_stats.h +322 -0
  470. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/cross_module_gil_utils.cpp +111 -0
  471. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/cross_module_interleaved_error_already_set.cpp +54 -0
  472. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/eigen_tensor_avoid_stl_array.cpp +16 -0
  473. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/env.py +31 -0
  474. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/extra_python_package/pytest.ini +0 -0
  475. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/extra_python_package/test_files.py +296 -0
  476. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/extra_setuptools/pytest.ini +0 -0
  477. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/extra_setuptools/test_setuphelper.py +153 -0
  478. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/local_bindings.h +92 -0
  479. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/object.h +205 -0
  480. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/pybind11_cross_module_tests.cpp +149 -0
  481. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/pybind11_tests.cpp +131 -0
  482. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/pybind11_tests.h +98 -0
  483. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/pytest.ini +23 -0
  484. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/requirements.txt +13 -0
  485. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/test_async.cpp +25 -0
  486. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/test_async.py +26 -0
  487. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/test_buffers.cpp +259 -0
  488. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/test_buffers.py +230 -0
  489. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/test_builtin_casters.cpp +387 -0
  490. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/test_builtin_casters.py +530 -0
  491. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/test_call_policies.cpp +113 -0
  492. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/test_call_policies.py +249 -0
  493. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/test_callbacks.cpp +280 -0
  494. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/test_callbacks.py +227 -0
  495. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/test_chrono.cpp +81 -0
  496. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/test_chrono.py +207 -0
  497. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/test_class.cpp +656 -0
  498. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/test_class.py +503 -0
  499. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/test_cmake_build/CMakeLists.txt +80 -0
  500. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/test_cmake_build/embed.cpp +23 -0
  501. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/test_cmake_build/installed_embed/CMakeLists.txt +28 -0
  502. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/test_cmake_build/installed_function/CMakeLists.txt +39 -0
  503. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/test_cmake_build/installed_target/CMakeLists.txt +46 -0
  504. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/test_cmake_build/main.cpp +6 -0
  505. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/test_cmake_build/subdirectory_embed/CMakeLists.txt +47 -0
  506. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/test_cmake_build/subdirectory_function/CMakeLists.txt +41 -0
  507. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/test_cmake_build/subdirectory_target/CMakeLists.txt +47 -0
  508. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/test_cmake_build/test.py +10 -0
  509. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/test_const_name.cpp +55 -0
  510. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/test_const_name.py +31 -0
  511. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/test_constants_and_functions.cpp +158 -0
  512. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/test_constants_and_functions.py +58 -0
  513. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/test_copy_move.cpp +544 -0
  514. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/test_copy_move.py +140 -0
  515. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/test_custom_type_casters.cpp +217 -0
  516. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/test_custom_type_casters.py +124 -0
  517. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/test_custom_type_setup.cpp +41 -0
  518. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/test_custom_type_setup.py +50 -0
  519. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/test_docstring_options.cpp +129 -0
  520. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/test_docstring_options.py +66 -0
  521. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/test_eigen_matrix.cpp +443 -0
  522. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/test_eigen_matrix.py +816 -0
  523. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/test_eigen_tensor.cpp +18 -0
  524. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/test_eigen_tensor.inl +332 -0
  525. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/test_eigen_tensor.py +290 -0
  526. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/test_embed/CMakeLists.txt +54 -0
  527. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/test_embed/catch.cpp +43 -0
  528. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/test_embed/external_module.cpp +20 -0
  529. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/test_embed/test_interpreter.cpp +488 -0
  530. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/test_embed/test_interpreter.py +16 -0
  531. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/test_embed/test_trampoline.py +18 -0
  532. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/test_enum.cpp +133 -0
  533. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/test_enum.py +270 -0
  534. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/test_eval.cpp +118 -0
  535. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/test_eval.py +52 -0
  536. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/test_eval_call.py +5 -0
  537. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/test_exceptions.cpp +388 -0
  538. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/test_exceptions.h +13 -0
  539. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/test_exceptions.py +434 -0
  540. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/test_factory_constructors.cpp +430 -0
  541. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/test_factory_constructors.py +518 -0
  542. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/test_gil_scoped.cpp +144 -0
  543. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/test_gil_scoped.py +244 -0
  544. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/test_iostream.cpp +126 -0
  545. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/test_iostream.py +293 -0
  546. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/test_kwargs_and_defaults.cpp +325 -0
  547. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/test_kwargs_and_defaults.py +428 -0
  548. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/test_local_bindings.cpp +106 -0
  549. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/test_local_bindings.py +259 -0
  550. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/test_methods_and_attributes.cpp +492 -0
  551. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/test_methods_and_attributes.py +539 -0
  552. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/test_modules.cpp +125 -0
  553. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/test_modules.py +118 -0
  554. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/test_multiple_inheritance.cpp +341 -0
  555. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/test_multiple_inheritance.py +495 -0
  556. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/test_numpy_array.cpp +547 -0
  557. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/test_numpy_array.py +672 -0
  558. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/test_numpy_dtypes.cpp +639 -0
  559. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/test_numpy_dtypes.py +448 -0
  560. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/test_numpy_vectorize.cpp +107 -0
  561. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/test_numpy_vectorize.py +268 -0
  562. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/test_opaque_types.cpp +77 -0
  563. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/test_opaque_types.py +60 -0
  564. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/test_operator_overloading.cpp +281 -0
  565. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/test_operator_overloading.py +153 -0
  566. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/test_pickling.cpp +194 -0
  567. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/test_pickling.py +95 -0
  568. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/test_python_multiple_inheritance.cpp +45 -0
  569. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/test_python_multiple_inheritance.py +36 -0
  570. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/test_pytypes.cpp +926 -0
  571. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/test_pytypes.py +1050 -0
  572. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/test_sequences_and_iterators.cpp +600 -0
  573. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/test_sequences_and_iterators.py +267 -0
  574. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/test_smart_ptr.cpp +473 -0
  575. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/test_smart_ptr.py +317 -0
  576. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/test_stl.cpp +549 -0
  577. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/test_stl.py +383 -0
  578. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/test_stl_binders.cpp +275 -0
  579. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/test_stl_binders.py +395 -0
  580. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/test_tagbased_polymorphic.cpp +147 -0
  581. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/test_tagbased_polymorphic.py +30 -0
  582. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/test_thread.cpp +66 -0
  583. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/test_thread.py +44 -0
  584. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/test_type_caster_pyobject_ptr.cpp +167 -0
  585. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/test_type_caster_pyobject_ptr.py +122 -0
  586. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/test_union.cpp +22 -0
  587. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/test_union.py +10 -0
  588. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/test_unnamed_namespace_a.cpp +38 -0
  589. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/test_unnamed_namespace_a.py +36 -0
  590. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/test_unnamed_namespace_b.cpp +13 -0
  591. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/test_unnamed_namespace_b.py +7 -0
  592. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/test_vector_unique_ptr_member.cpp +54 -0
  593. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/test_vector_unique_ptr_member.py +16 -0
  594. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/test_virtual_functions.cpp +592 -0
  595. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/test_virtual_functions.py +460 -0
  596. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/valgrind-numpy-scipy.supp +140 -0
  597. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tests/valgrind-python.supp +117 -0
  598. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tools/FindCatch.cmake +76 -0
  599. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tools/FindEigen3.cmake +86 -0
  600. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tools/FindPythonLibsNew.cmake +310 -0
  601. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tools/JoinPaths.cmake +23 -0
  602. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tools/check-style.sh +44 -0
  603. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tools/cmake_uninstall.cmake.in +23 -0
  604. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tools/codespell_ignore_lines_from_errors.py +40 -0
  605. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tools/libsize.py +38 -0
  606. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tools/make_changelog.py +92 -0
  607. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tools/pybind11.pc.in +7 -0
  608. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tools/pybind11Common.cmake +429 -0
  609. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tools/pybind11Config.cmake.in +233 -0
  610. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tools/pybind11GuessPythonExtSuffix.cmake +86 -0
  611. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tools/pybind11NewTools.cmake +341 -0
  612. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tools/pybind11Tools.cmake +239 -0
  613. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tools/pyproject.toml +3 -0
  614. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tools/setup_global.py.in +63 -0
  615. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tools/setup_main.py.in +44 -0
  616. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/pybind11/tools/test-pybind11GuessPythonExtSuffix.cmake +161 -0
  617. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/setup.py +76 -0
  618. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Python/unit_test.py +209 -0
  619. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/README.md +357 -0
  620. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/README_CN.md +301 -0
  621. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/SECURITY.md +15 -0
  622. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Script/dumpJavaSignature.py +144 -0
  623. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Script/formatCode.py +17 -0
  624. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Win32/.clang-format +35 -0
  625. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Win32/Win32.sln +58 -0
  626. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Win32/Win32Demo/Win32Demo.cpp +548 -0
  627. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Win32/Win32Demo/Win32Demo.vcxproj +190 -0
  628. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Win32/Win32Demo/Win32Demo.vcxproj.filters +30 -0
  629. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Win32/Win32Demo/pch.cpp +23 -0
  630. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Win32/Win32Demo/pch.h +28 -0
  631. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Win32/Win32DemoProcess/Win32DemoProcess.cpp +88 -0
  632. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Win32/Win32DemoProcess/Win32DemoProcess.vcxproj +188 -0
  633. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Win32/Win32DemoProcess/Win32DemoProcess.vcxproj.filters +30 -0
  634. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Win32/Win32DemoProcess/pch.cpp +21 -0
  635. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/Win32/Win32DemoProcess/pch.h +24 -0
  636. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/.metadata +10 -0
  637. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/.vscode/launch.json +162 -0
  638. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/.vscode/settings.json +12 -0
  639. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/CHANGELOG.md +196 -0
  640. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/LICENSE +193 -0
  641. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/README.md +217 -0
  642. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/analysis_options.yaml +49 -0
  643. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/README.md +16 -0
  644. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/android/app/build.gradle +79 -0
  645. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/android/app/src/main/AndroidManifest.xml +41 -0
  646. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/android/app/src/main/java/com/tencent/mmkv_example/MainActivity.java +25 -0
  647. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/android/app/src/main/res/drawable/launch_background.xml +12 -0
  648. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png +0 -0
  649. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png +0 -0
  650. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png +0 -0
  651. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png +0 -0
  652. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png +0 -0
  653. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/android/app/src/main/res/values/styles.xml +18 -0
  654. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/android/app/src/profile/AndroidManifest.xml +7 -0
  655. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/android/build.gradle +29 -0
  656. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/android/gradle/wrapper/gradle-wrapper.properties +6 -0
  657. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/android/gradle.properties +4 -0
  658. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/android/settings.gradle +25 -0
  659. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/android/settings_aar.gradle +1 -0
  660. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/ios/Flutter/AppFrameworkInfo.plist +26 -0
  661. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/ios/Flutter/Debug.xcconfig +2 -0
  662. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/ios/Flutter/Release.xcconfig +2 -0
  663. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/ios/Flutter/ephemeral/flutter_lldb_helper.py +32 -0
  664. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/ios/Flutter/ephemeral/flutter_lldbinit +5 -0
  665. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/ios/Podfile +49 -0
  666. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/ios/Runner/AppDelegate.h +26 -0
  667. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/ios/Runner/AppDelegate.m +33 -0
  668. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json +122 -0
  669. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png +0 -0
  670. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png +0 -0
  671. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png +0 -0
  672. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png +0 -0
  673. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png +0 -0
  674. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png +0 -0
  675. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png +0 -0
  676. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png +0 -0
  677. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png +0 -0
  678. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png +0 -0
  679. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png +0 -0
  680. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png +0 -0
  681. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png +0 -0
  682. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png +0 -0
  683. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png +0 -0
  684. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json +23 -0
  685. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png +0 -0
  686. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png +0 -0
  687. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png +0 -0
  688. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md +5 -0
  689. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/ios/Runner/Base.lproj/LaunchScreen.storyboard +37 -0
  690. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/ios/Runner/Base.lproj/Main.storyboard +29 -0
  691. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/ios/Runner/Info.plist +49 -0
  692. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/ios/Runner/Runner.entitlements +10 -0
  693. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/ios/Runner/main.m +29 -0
  694. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/ios/Runner.xcodeproj/project.pbxproj +612 -0
  695. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  696. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  697. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings +8 -0
  698. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +90 -0
  699. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/ios/Runner.xcworkspace/contents.xcworkspacedata +10 -0
  700. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  701. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings +8 -0
  702. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/lib/main.dart +565 -0
  703. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/linux/CMakeLists.txt +128 -0
  704. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/linux/flutter/CMakeLists.txt +88 -0
  705. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/linux/flutter/generated_plugin_registrant.cc +15 -0
  706. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/linux/flutter/generated_plugin_registrant.h +15 -0
  707. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/linux/flutter/generated_plugins.cmake +24 -0
  708. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/linux/runner/CMakeLists.txt +26 -0
  709. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/linux/runner/main.cc +6 -0
  710. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/linux/runner/my_application.cc +130 -0
  711. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/linux/runner/my_application.h +18 -0
  712. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/macos/Flutter/Flutter-Debug.xcconfig +2 -0
  713. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/macos/Flutter/Flutter-Release.xcconfig +2 -0
  714. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/macos/Flutter/GeneratedPluginRegistrant.swift +14 -0
  715. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/macos/Podfile +47 -0
  716. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/macos/Runner/AppDelegate.swift +13 -0
  717. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json +68 -0
  718. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png +0 -0
  719. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png +0 -0
  720. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png +0 -0
  721. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png +0 -0
  722. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png +0 -0
  723. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png +0 -0
  724. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png +0 -0
  725. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/macos/Runner/Base.lproj/MainMenu.xib +343 -0
  726. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/macos/Runner/Configs/AppInfo.xcconfig +14 -0
  727. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/macos/Runner/Configs/Debug.xcconfig +2 -0
  728. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/macos/Runner/Configs/Release.xcconfig +2 -0
  729. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/macos/Runner/Configs/Warnings.xcconfig +13 -0
  730. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/macos/Runner/DebugProfile.entitlements +12 -0
  731. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/macos/Runner/Info.plist +32 -0
  732. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/macos/Runner/MainFlutterWindow.swift +15 -0
  733. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/macos/Runner/Release.entitlements +8 -0
  734. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/macos/Runner.xcodeproj/project.pbxproj +800 -0
  735. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  736. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +99 -0
  737. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/macos/Runner.xcworkspace/contents.xcworkspacedata +10 -0
  738. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  739. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/macos/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings +5 -0
  740. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/macos/RunnerTests/RunnerTests.swift +12 -0
  741. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/ohos/AppScope/app.json5 +10 -0
  742. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/ohos/AppScope/resources/base/element/string.json +8 -0
  743. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/ohos/AppScope/resources/base/media/app_icon.png +0 -0
  744. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/ohos/build-profile.json5 +41 -0
  745. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/ohos/entry/build-profile.json5 +34 -0
  746. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/ohos/entry/hvigorfile.ts +17 -0
  747. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/ohos/entry/oh-package.json5 +13 -0
  748. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/ohos/entry/src/main/ets/entryability/EntryAbility.ets +36 -0
  749. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/ohos/entry/src/main/ets/pages/Index.ets +38 -0
  750. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/ohos/entry/src/main/ets/plugins/GeneratedPluginRegistrant.ets +28 -0
  751. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/ohos/entry/src/main/module.json5 +53 -0
  752. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/ohos/entry/src/main/resources/base/element/color.json +8 -0
  753. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/ohos/entry/src/main/resources/base/element/string.json +16 -0
  754. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/ohos/entry/src/main/resources/base/media/icon.png +0 -0
  755. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/ohos/entry/src/main/resources/base/profile/main_pages.json +5 -0
  756. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/ohos/entry/src/main/resources/en_US/element/string.json +16 -0
  757. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/ohos/entry/src/main/resources/zh_CN/element/string.json +16 -0
  758. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/ohos/entry/src/ohosTest/ets/test/Ability.test.ets +50 -0
  759. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/ohos/entry/src/ohosTest/ets/test/List.test.ets +20 -0
  760. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/ohos/entry/src/ohosTest/ets/testability/TestAbility.ets +63 -0
  761. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/ohos/entry/src/ohosTest/ets/testability/pages/Index.ets +49 -0
  762. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/ohos/entry/src/ohosTest/ets/testrunner/OpenHarmonyTestRunner.ts +64 -0
  763. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/ohos/entry/src/ohosTest/module.json5 +51 -0
  764. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/ohos/entry/src/ohosTest/resources/base/element/color.json +8 -0
  765. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/ohos/entry/src/ohosTest/resources/base/element/string.json +16 -0
  766. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/ohos/entry/src/ohosTest/resources/base/media/icon.png +0 -0
  767. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/ohos/entry/src/ohosTest/resources/base/profile/test_pages.json +5 -0
  768. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/ohos/hvigor/hvigor-config.json5 +20 -0
  769. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/ohos/hvigorfile.ts +21 -0
  770. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/ohos/oh-package.json5 +21 -0
  771. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/pubspec.yaml +75 -0
  772. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/windows/CMakeLists.txt +108 -0
  773. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/windows/flutter/CMakeLists.txt +109 -0
  774. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/windows/flutter/generated_plugin_registrant.cc +14 -0
  775. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/windows/flutter/generated_plugin_registrant.h +15 -0
  776. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/windows/flutter/generated_plugins.cmake +24 -0
  777. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/windows/runner/CMakeLists.txt +40 -0
  778. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/windows/runner/Runner.rc +121 -0
  779. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/windows/runner/flutter_window.cpp +71 -0
  780. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/windows/runner/flutter_window.h +33 -0
  781. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/windows/runner/main.cpp +43 -0
  782. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/windows/runner/resource.h +16 -0
  783. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/windows/runner/resources/app_icon.ico +0 -0
  784. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/windows/runner/runner.exe.manifest +14 -0
  785. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/windows/runner/utils.cpp +65 -0
  786. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/windows/runner/utils.h +19 -0
  787. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/windows/runner/win32_window.cpp +288 -0
  788. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/example/windows/runner/win32_window.h +102 -0
  789. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/lib/mmkv.dart +1052 -0
  790. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/mmkv.iml +17 -0
  791. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/pubspec.yaml +62 -0
  792. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/test/mmkv_test.dart +48 -0
  793. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/tool/fix_mmkv_plugin_name.rb +4 -0
  794. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv/tool/mmkvpodhelper.rb +23 -0
  795. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv.iml +25 -0
  796. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv_android/CHANGELOG.md +48 -0
  797. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv_android/LICENSE +193 -0
  798. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv_android/README.md +17 -0
  799. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv_android/android/build.gradle +39 -0
  800. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv_android/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  801. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv_android/android/gradle/wrapper/gradle-wrapper.properties +5 -0
  802. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv_android/android/gradle.properties +4 -0
  803. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv_android/android/gradlew +160 -0
  804. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv_android/android/gradlew.bat +90 -0
  805. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv_android/android/settings.gradle +1 -0
  806. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv_android/android/src/main/AndroidManifest.xml +1 -0
  807. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv_android/android/src/main/java/com/tencent/mmkv/MMKVPlugin.java +82 -0
  808. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv_android/lib/mmkv_android.dart +76 -0
  809. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv_android/pubspec.yaml +40 -0
  810. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv_ios/.metadata +33 -0
  811. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv_ios/CHANGELOG.md +52 -0
  812. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv_ios/LICENSE +193 -0
  813. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv_ios/README.md +17 -0
  814. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv_ios/darwin/Classes/MMKVPlugin.h +28 -0
  815. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv_ios/darwin/Classes/MMKVPlugin.mm +39 -0
  816. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv_ios/darwin/Classes/flutter-bridge.h +32 -0
  817. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv_ios/darwin/Classes/flutter-bridge.mm +693 -0
  818. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv_ios/darwin/mmkv_ios.podspec +35 -0
  819. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv_ios/lib/mmkv_ios.dart +78 -0
  820. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv_ios/pubspec.yaml +44 -0
  821. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv_linux/.metadata +30 -0
  822. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv_linux/CHANGELOG.md +9 -0
  823. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv_linux/LICENSE +193 -0
  824. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv_linux/README.md +17 -0
  825. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv_linux/analysis_options.yaml +4 -0
  826. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv_linux/lib/mmkv_linux.dart +69 -0
  827. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv_linux/linux/CMakeLists.txt +63 -0
  828. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv_linux/linux/flutter-bridge.cpp +694 -0
  829. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv_linux/linux/include/mmkv_linux/mmkv_linux_plugin.h +46 -0
  830. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv_linux/linux/mmkv_linux_plugin.cc +97 -0
  831. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv_linux/pubspec.yaml +47 -0
  832. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv_ohos/.metadata +30 -0
  833. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv_ohos/CHANGELOG.md +42 -0
  834. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv_ohos/LICENSE +193 -0
  835. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv_ohos/README.md +17 -0
  836. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv_ohos/analysis_options.yaml +4 -0
  837. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv_ohos/lib/mmkv_ohos.dart +84 -0
  838. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv_ohos/ohos/build-profile.json5 +10 -0
  839. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv_ohos/ohos/hvigorfile.ts +2 -0
  840. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv_ohos/ohos/index.ets +17 -0
  841. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv_ohos/ohos/oh-package.json5 +15 -0
  842. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv_ohos/ohos/src/main/ets/components/plugin/MMKVPlugin.ets +78 -0
  843. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv_ohos/ohos/src/main/module.json5 +10 -0
  844. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv_ohos/pubspec.yaml +50 -0
  845. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv_platform_interface/CHANGELOG.md +38 -0
  846. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv_platform_interface/LICENSE +193 -0
  847. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv_platform_interface/README.md +30 -0
  848. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv_platform_interface/lib/mmkv_platform_ffi.dart +363 -0
  849. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv_platform_interface/lib/mmkv_platform_interface.dart +363 -0
  850. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv_platform_interface/pubspec.yaml +23 -0
  851. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv_win32/.metadata +30 -0
  852. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv_win32/CHANGELOG.md +9 -0
  853. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv_win32/LICENSE +193 -0
  854. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv_win32/README.md +17 -0
  855. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv_win32/analysis_options.yaml +4 -0
  856. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv_win32/lib/mmkv_win32.dart +69 -0
  857. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv_win32/pubspec.yaml +47 -0
  858. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv_win32/windows/CMakeLists.txt +71 -0
  859. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv_win32/windows/flutter-bridge.cpp +721 -0
  860. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv_win32/windows/include/mmkv_win32/mmkv_win32_plugin.h +43 -0
  861. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/flutter/mmkv_win32/windows/mmkv_win32_plugin.cpp +88 -0
  862. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKV/MMKV/AutoCleanInfo.hpp +65 -0
  863. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKV/MMKV/MMKV.h +552 -0
  864. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKV/MMKV/MMKVHandler.h +60 -0
  865. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKV/MMKV/Resources/Info.plist +24 -0
  866. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKV/MMKV/libMMKV.mm +1361 -0
  867. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKV/MMKV.xcodeproj/project.pbxproj +967 -0
  868. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKV/MMKV.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  869. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKV/MMKV.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  870. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKV/MMKV.xcodeproj/xcshareddata/xcschemes/MMKV For App Extension.xcscheme +67 -0
  871. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKV/MMKV.xcodeproj/xcshareddata/xcschemes/MMKV Static.xcscheme +76 -0
  872. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKV/MMKV.xcodeproj/xcshareddata/xcschemes/MMKV.xcscheme +76 -0
  873. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKV/MMKV.xcodeproj/xcshareddata/xcschemes/MMKVWatchExtension.xcscheme +67 -0
  874. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKVDemo/Config.xcconfig +10 -0
  875. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKVDemo/MMKVCatalystDemo/AppDelegate.h +15 -0
  876. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKVDemo/MMKVCatalystDemo/AppDelegate.m +43 -0
  877. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKVDemo/MMKVCatalystDemo/Assets.xcassets/AccentColor.colorset/Contents.json +11 -0
  878. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKVDemo/MMKVCatalystDemo/Assets.xcassets/AppIcon.appiconset/Contents.json +13 -0
  879. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKVDemo/MMKVCatalystDemo/Assets.xcassets/Contents.json +6 -0
  880. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKVDemo/MMKVCatalystDemo/Base.lproj/LaunchScreen.storyboard +25 -0
  881. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKVDemo/MMKVCatalystDemo/Base.lproj/Main.storyboard +42 -0
  882. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKVDemo/MMKVCatalystDemo/Info.plist +25 -0
  883. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKVDemo/MMKVCatalystDemo/MMKVCatalystDemo.entitlements +12 -0
  884. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKVDemo/MMKVCatalystDemo/SceneDelegate.h +16 -0
  885. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKVDemo/MMKVCatalystDemo/SceneDelegate.m +58 -0
  886. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKVDemo/MMKVCatalystDemo/ViewController.h +15 -0
  887. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKVDemo/MMKVCatalystDemo/ViewController.mm +85 -0
  888. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKVDemo/MMKVCatalystDemo/main.m +19 -0
  889. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKVDemo/MMKVDemo/AppDelegate.h +27 -0
  890. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKVDemo/MMKVDemo/AppDelegate.m +135 -0
  891. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKVDemo/MMKVDemo/DemoSwiftUsage.swift +82 -0
  892. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKVDemo/MMKVDemo/MMKVDemo-Bridging-Header.h +22 -0
  893. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKVDemo/MMKVDemo/Resources/Assets.xcassets/AppIcon.appiconset/Contents.json +98 -0
  894. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKVDemo/MMKVDemo/Resources/Base.lproj/LaunchScreen.storyboard +25 -0
  895. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKVDemo/MMKVDemo/Resources/Base.lproj/Main.storyboard +48 -0
  896. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKVDemo/MMKVDemo/Resources/Info.plist +49 -0
  897. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKVDemo/MMKVDemo/Resources/MMKVDemo.entitlements +10 -0
  898. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKVDemo/MMKVDemo/Resources/testReadOnly +0 -0
  899. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKVDemo/MMKVDemo/Resources/testReadOnly.crc +0 -0
  900. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKVDemo/MMKVDemo/TestMMKVCpp.cpp +204 -0
  901. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKVDemo/MMKVDemo/TestMMKVCpp.hpp +18 -0
  902. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKVDemo/MMKVDemo/ViewController+TestCaseBad.h +39 -0
  903. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKVDemo/MMKVDemo/ViewController+TestCaseBad.mm +200 -0
  904. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKVDemo/MMKVDemo/ViewController.h +32 -0
  905. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKVDemo/MMKVDemo/ViewController.mm +1245 -0
  906. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKVDemo/MMKVDemo/main.m +28 -0
  907. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKVDemo/MMKVDemo.xcodeproj/project.pbxproj +1944 -0
  908. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKVDemo/MMKVDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  909. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKVDemo/MMKVDemo.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  910. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKVDemo/MMKVDemo.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings +8 -0
  911. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKVDemo/MMKVDemo.xcodeproj/xcshareddata/xcschemes/MMKVDemo.xcscheme +88 -0
  912. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKVDemo/MMKVDemo.xcodeproj/xcshareddata/xcschemes/MMKVMacDemo.xcscheme +78 -0
  913. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKVDemo/MMKVDemo.xcodeproj/xcshareddata/xcschemes/MMKVTodayExtensionDemo.xcscheme +116 -0
  914. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKVDemo/MMKVDemo.xcodeproj/xcshareddata/xcschemes/WatchApp (Notification).xcscheme +106 -0
  915. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKVDemo/MMKVDemo.xcodeproj/xcshareddata/xcschemes/WatchApp.xcscheme +102 -0
  916. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKVDemo/MMKVDemo.xcodeproj/xcshareddata/xcschemes/kvdemo.xcscheme +78 -0
  917. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKVDemo/MMKVDemoTests/Info.plist +22 -0
  918. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKVDemo/MMKVDemoTests/MMKVDemoTests.mm +554 -0
  919. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKVDemo/MMKVDemoTests/MMKVPerformanceTest.mm +118 -0
  920. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKVDemo/MMKVMacDemo/AppDelegate.h +13 -0
  921. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKVDemo/MMKVMacDemo/AppDelegate.m +27 -0
  922. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKVDemo/MMKVMacDemo/Assets.xcassets/AppIcon.appiconset/Contents.json +58 -0
  923. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKVDemo/MMKVMacDemo/Assets.xcassets/Contents.json +6 -0
  924. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKVDemo/MMKVMacDemo/Base.lproj/Main.storyboard +718 -0
  925. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKVDemo/MMKVMacDemo/Info.plist +32 -0
  926. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKVDemo/MMKVMacDemo/MMKVMacDemo.entitlements +10 -0
  927. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKVDemo/MMKVMacDemo/ViewController.h +13 -0
  928. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKVDemo/MMKVMacDemo/ViewController.mm +352 -0
  929. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKVDemo/MMKVMacDemo/main.m +15 -0
  930. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKVDemo/MMKVTodayExtensionDemo/Base.lproj/MainInterface.storyboard +45 -0
  931. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKVDemo/MMKVTodayExtensionDemo/Info.plist +31 -0
  932. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKVDemo/MMKVTodayExtensionDemo/MMKVTodayExtensionDemo.entitlements +10 -0
  933. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKVDemo/MMKVTodayExtensionDemo/TodayViewController.h +25 -0
  934. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKVDemo/MMKVTodayExtensionDemo/TodayViewController.m +106 -0
  935. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKVDemo/MMKVVisionDemo/Assets.xcassets/AppIcon.solidimagestack/Back.solidimagestacklayer/Content.imageset/Contents.json +12 -0
  936. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKVDemo/MMKVVisionDemo/Assets.xcassets/AppIcon.solidimagestack/Back.solidimagestacklayer/Contents.json +6 -0
  937. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKVDemo/MMKVVisionDemo/Assets.xcassets/AppIcon.solidimagestack/Contents.json +17 -0
  938. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKVDemo/MMKVVisionDemo/Assets.xcassets/AppIcon.solidimagestack/Front.solidimagestacklayer/Content.imageset/Contents.json +12 -0
  939. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKVDemo/MMKVVisionDemo/Assets.xcassets/AppIcon.solidimagestack/Front.solidimagestacklayer/Contents.json +6 -0
  940. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKVDemo/MMKVVisionDemo/Assets.xcassets/AppIcon.solidimagestack/Middle.solidimagestacklayer/Content.imageset/Contents.json +12 -0
  941. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKVDemo/MMKVVisionDemo/Assets.xcassets/AppIcon.solidimagestack/Middle.solidimagestacklayer/Contents.json +6 -0
  942. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKVDemo/MMKVVisionDemo/Assets.xcassets/Contents.json +6 -0
  943. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKVDemo/MMKVVisionDemo/ContentView.swift +71 -0
  944. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKVDemo/MMKVVisionDemo/Info.plist +15 -0
  945. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKVDemo/MMKVVisionDemo/MMKVVisionDemoApp.swift +22 -0
  946. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKVDemo/MMKVVisionDemo/Preview Content/Preview Assets.xcassets/Contents.json +6 -0
  947. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKVDemo/WatchApp/Assets.xcassets/AppIcon.appiconset/Contents.json +81 -0
  948. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKVDemo/WatchApp/Assets.xcassets/Contents.json +6 -0
  949. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKVDemo/WatchApp/Base.lproj/Interface.storyboard +47 -0
  950. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKVDemo/WatchApp/Info.plist +33 -0
  951. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKVDemo/WatchApp Extension/Assets.xcassets/Complication.complicationset/Circular.imageset/Contents.json +28 -0
  952. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKVDemo/WatchApp Extension/Assets.xcassets/Complication.complicationset/Contents.json +48 -0
  953. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKVDemo/WatchApp Extension/Assets.xcassets/Complication.complicationset/Extra Large.imageset/Contents.json +28 -0
  954. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKVDemo/WatchApp Extension/Assets.xcassets/Complication.complicationset/Graphic Bezel.imageset/Contents.json +28 -0
  955. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKVDemo/WatchApp Extension/Assets.xcassets/Complication.complicationset/Graphic Circular.imageset/Contents.json +28 -0
  956. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKVDemo/WatchApp Extension/Assets.xcassets/Complication.complicationset/Graphic Corner.imageset/Contents.json +28 -0
  957. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKVDemo/WatchApp Extension/Assets.xcassets/Complication.complicationset/Graphic Large Rectangular.imageset/Contents.json +28 -0
  958. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKVDemo/WatchApp Extension/Assets.xcassets/Complication.complicationset/Modular.imageset/Contents.json +28 -0
  959. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKVDemo/WatchApp Extension/Assets.xcassets/Complication.complicationset/Utilitarian.imageset/Contents.json +28 -0
  960. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKVDemo/WatchApp Extension/Assets.xcassets/Contents.json +6 -0
  961. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKVDemo/WatchApp Extension/ExtensionDelegate.h +25 -0
  962. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKVDemo/WatchApp Extension/ExtensionDelegate.mm +135 -0
  963. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKVDemo/WatchApp Extension/Info.plist +36 -0
  964. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKVDemo/WatchApp Extension/InterfaceController.h +26 -0
  965. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKVDemo/WatchApp Extension/InterfaceController.m +50 -0
  966. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKVDemo/WatchApp Extension/NotificationController.h +26 -0
  967. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKVDemo/WatchApp Extension/NotificationController.m +60 -0
  968. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKVDemo/WatchApp Extension/PushNotificationPayload.apns +20 -0
  969. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKVDemo/kvdemo/AppDelegate.h +15 -0
  970. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKVDemo/kvdemo/AppDelegate.m +49 -0
  971. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKVDemo/kvdemo/Assets.xcassets/AccentColor.colorset/Contents.json +11 -0
  972. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKVDemo/kvdemo/Assets.xcassets/AppIcon.appiconset/Contents.json +13 -0
  973. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKVDemo/kvdemo/Assets.xcassets/Contents.json +6 -0
  974. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKVDemo/kvdemo/Base.lproj/LaunchScreen.storyboard +25 -0
  975. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKVDemo/kvdemo/Base.lproj/Main.storyboard +45 -0
  976. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKVDemo/kvdemo/Info.plist +25 -0
  977. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKVDemo/kvdemo/SceneDelegate.h +16 -0
  978. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKVDemo/kvdemo/SceneDelegate.m +58 -0
  979. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKVDemo/kvdemo/ViewController.h +15 -0
  980. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKVDemo/kvdemo/ViewController.m +38 -0
  981. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKVDemo/kvdemo/kvdemo.entitlements +10 -0
  982. package/harmony/reactNativeMMKV/src/main/cpp/MMKV/iOS/MMKVDemo/kvdemo/main.m +19 -0
  983. package/harmony/reactNativeMMKV/src/main/cpp/MMKVManagedBuffer.h +49 -0
  984. package/harmony/reactNativeMMKV/src/main/cpp/MmkvCxx.cpp +152 -0
  985. package/harmony/reactNativeMMKV/src/main/cpp/MmkvCxx.h +36 -0
  986. package/harmony/reactNativeMMKV/src/main/cpp/MmkvHostObject.cpp +357 -0
  987. package/harmony/reactNativeMMKV/src/main/cpp/MmkvHostObject.h +66 -0
  988. package/harmony/reactNativeMMKV/src/main/cpp/MmkvLogger.h +52 -0
  989. package/harmony/reactNativeMMKV/src/main/cpp/MmkvPlatformContext.cpp +37 -0
  990. package/harmony/reactNativeMMKV/src/main/cpp/MmkvPlatformContext.h +36 -0
  991. package/harmony/reactNativeMMKV/src/main/cpp/NativeMMKVComponentDescriptor.h +65 -0
  992. package/harmony/reactNativeMMKV/src/main/cpp/NativeMMKVJSIBinder.h +55 -0
  993. package/harmony/reactNativeMMKV/src/main/cpp/NativeMMKVPackage.h +67 -0
  994. package/harmony/reactNativeMMKV/src/main/cpp/Props.cpp +37 -0
  995. package/harmony/reactNativeMMKV/src/main/cpp/Props.h +42 -0
  996. package/harmony/reactNativeMMKV/src/main/cpp/ShadowNodes.cpp +39 -0
  997. package/harmony/reactNativeMMKV/src/main/cpp/ShadowNodes.h +41 -0
  998. package/harmony/reactNativeMMKV/src/main/cpp/States.cpp +40 -0
  999. package/harmony/reactNativeMMKV/src/main/cpp/States.h +45 -0
  1000. package/harmony/reactNativeMMKV/src/main/ets/Logger.ts +65 -0
  1001. package/harmony/reactNativeMMKV/src/main/ets/MmkvCxxPackage.ts +46 -0
  1002. package/harmony/reactNativeMMKV/src/main/ets/MmkvCxxTurboModule.ts +60 -0
  1003. package/harmony/reactNativeMMKV/src/main/ets/MmkvPlatformContextPackage.ts +46 -0
  1004. package/harmony/reactNativeMMKV/src/main/ets/MmkvPlatformContextTurboModule.ts +48 -0
  1005. package/harmony/reactNativeMMKV/src/main/module.json5 +7 -0
  1006. package/harmony/reactNativeMMKV/src/main/resources/base/element/string.json +8 -0
  1007. package/harmony/reactNativeMMKV/src/main/resources/en_US/element/string.json +8 -0
  1008. package/harmony/reactNativeMMKV/src/main/resources/zh_CN/element/string.json +8 -0
  1009. package/harmony/reactNativeMMKV/ts.ts +27 -0
  1010. package/harmony/reactNativeMMKV.har +0 -0
  1011. package/lib/commonjs/MMKV.js +124 -0
  1012. package/lib/commonjs/MMKV.js.map +1 -0
  1013. package/lib/commonjs/MemoryWarningListener.js +31 -0
  1014. package/lib/commonjs/MemoryWarningListener.js.map +1 -0
  1015. package/lib/commonjs/MemoryWarningListener.web.js +11 -0
  1016. package/lib/commonjs/MemoryWarningListener.web.js.map +1 -0
  1017. package/lib/commonjs/ModuleNotFoundError.js +75 -0
  1018. package/lib/commonjs/ModuleNotFoundError.js.map +1 -0
  1019. package/lib/commonjs/NativeMmkv.js +53 -0
  1020. package/lib/commonjs/NativeMmkv.js.map +1 -0
  1021. package/lib/commonjs/NativeMmkvPlatformContext.js +22 -0
  1022. package/lib/commonjs/NativeMmkvPlatformContext.js.map +1 -0
  1023. package/lib/commonjs/PlatformChecker.js +14 -0
  1024. package/lib/commonjs/PlatformChecker.js.map +1 -0
  1025. package/lib/commonjs/Types.js +32 -0
  1026. package/lib/commonjs/Types.js.map +1 -0
  1027. package/lib/commonjs/createMMKV.js +43 -0
  1028. package/lib/commonjs/createMMKV.js.map +1 -0
  1029. package/lib/commonjs/createMMKV.mock.js +43 -0
  1030. package/lib/commonjs/createMMKV.mock.js.map +1 -0
  1031. package/lib/commonjs/createMMKV.web.js +110 -0
  1032. package/lib/commonjs/createMMKV.web.js.map +1 -0
  1033. package/lib/commonjs/createTextEncoder.js +23 -0
  1034. package/lib/commonjs/createTextEncoder.js.map +1 -0
  1035. package/lib/commonjs/hooks.js +198 -0
  1036. package/lib/commonjs/hooks.js.map +1 -0
  1037. package/lib/commonjs/index.js +40 -0
  1038. package/lib/commonjs/index.js.map +1 -0
  1039. package/lib/commonjs/package.json +1 -0
  1040. package/lib/module/MMKV.js +119 -0
  1041. package/lib/module/MMKV.js.map +1 -0
  1042. package/lib/module/MemoryWarningListener.js +27 -0
  1043. package/lib/module/MemoryWarningListener.js.map +1 -0
  1044. package/lib/module/MemoryWarningListener.web.js +6 -0
  1045. package/lib/module/MemoryWarningListener.web.js.map +1 -0
  1046. package/lib/module/ModuleNotFoundError.js +70 -0
  1047. package/lib/module/ModuleNotFoundError.js.map +1 -0
  1048. package/lib/module/NativeMmkv.js +51 -0
  1049. package/lib/module/NativeMmkv.js.map +1 -0
  1050. package/lib/module/NativeMmkvPlatformContext.js +18 -0
  1051. package/lib/module/NativeMmkvPlatformContext.js.map +1 -0
  1052. package/lib/module/PlatformChecker.js +10 -0
  1053. package/lib/module/PlatformChecker.js.map +1 -0
  1054. package/lib/module/Types.js +31 -0
  1055. package/lib/module/Types.js.map +1 -0
  1056. package/lib/module/createMMKV.js +38 -0
  1057. package/lib/module/createMMKV.js.map +1 -0
  1058. package/lib/module/createMMKV.mock.js +38 -0
  1059. package/lib/module/createMMKV.mock.js.map +1 -0
  1060. package/lib/module/createMMKV.web.js +105 -0
  1061. package/lib/module/createMMKV.web.js.map +1 -0
  1062. package/lib/module/createTextEncoder.js +19 -0
  1063. package/lib/module/createTextEncoder.js.map +1 -0
  1064. package/lib/module/hooks.js +189 -0
  1065. package/lib/module/hooks.js.map +1 -0
  1066. package/lib/module/index.js +6 -0
  1067. package/lib/module/index.js.map +1 -0
  1068. package/lib/typescript/src/MMKV.d.ts +34 -0
  1069. package/lib/typescript/src/MMKV.d.ts.map +1 -0
  1070. package/lib/typescript/src/MemoryWarningListener.d.ts +3 -0
  1071. package/lib/typescript/src/MemoryWarningListener.d.ts.map +1 -0
  1072. package/lib/typescript/src/MemoryWarningListener.web.d.ts +3 -0
  1073. package/lib/typescript/src/MemoryWarningListener.web.d.ts.map +1 -0
  1074. package/lib/typescript/src/ModuleNotFoundError.d.ts +7 -0
  1075. package/lib/typescript/src/ModuleNotFoundError.d.ts.map +1 -0
  1076. package/lib/typescript/src/NativeMmkv.d.ts +91 -0
  1077. package/lib/typescript/src/NativeMmkv.d.ts.map +1 -0
  1078. package/lib/typescript/src/NativeMmkvPlatformContext.d.ts +20 -0
  1079. package/lib/typescript/src/NativeMmkvPlatformContext.d.ts.map +1 -0
  1080. package/lib/typescript/src/PlatformChecker.d.ts +2 -0
  1081. package/lib/typescript/src/PlatformChecker.d.ts.map +1 -0
  1082. package/lib/typescript/src/Types.d.ts +172 -0
  1083. package/lib/typescript/src/Types.d.ts.map +1 -0
  1084. package/lib/typescript/src/__tests__/hooks.test.d.ts +2 -0
  1085. package/lib/typescript/src/__tests__/hooks.test.d.ts.map +1 -0
  1086. package/lib/typescript/src/createMMKV.d.ts +3 -0
  1087. package/lib/typescript/src/createMMKV.d.ts.map +1 -0
  1088. package/lib/typescript/src/createMMKV.mock.d.ts +3 -0
  1089. package/lib/typescript/src/createMMKV.mock.d.ts.map +1 -0
  1090. package/lib/typescript/src/createMMKV.web.d.ts +3 -0
  1091. package/lib/typescript/src/createMMKV.web.d.ts.map +1 -0
  1092. package/lib/typescript/src/createTextEncoder.d.ts +2 -0
  1093. package/lib/typescript/src/createTextEncoder.d.ts.map +1 -0
  1094. package/lib/typescript/src/hooks.d.ts +86 -0
  1095. package/lib/typescript/src/hooks.d.ts.map +1 -0
  1096. package/lib/typescript/src/index.d.ts +4 -0
  1097. package/lib/typescript/src/index.d.ts.map +1 -0
  1098. package/package.json +187 -0
  1099. package/react-native-mmkv.podspec +38 -0
  1100. package/react-native.config.js +20 -0
  1101. package/src/MMKV.ts +142 -0
  1102. package/src/MemoryWarningListener.ts +29 -0
  1103. package/src/MemoryWarningListener.web.ts +5 -0
  1104. package/src/ModuleNotFoundError.ts +95 -0
  1105. package/src/NativeMmkv.ts +118 -0
  1106. package/src/NativeMmkvPlatformContext.ts +38 -0
  1107. package/src/PlatformChecker.ts +9 -0
  1108. package/src/Types.ts +178 -0
  1109. package/src/__tests__/hooks.test.tsx +89 -0
  1110. package/src/createMMKV.mock.ts +38 -0
  1111. package/src/createMMKV.ts +42 -0
  1112. package/src/createMMKV.web.ts +127 -0
  1113. package/src/createTextEncoder.ts +16 -0
  1114. package/src/hooks.ts +247 -0
  1115. package/src/index.ts +4 -0
@@ -0,0 +1,3026 @@
1
+ /*
2
+ pybind11/pybind11.h: Main header file of the C++11 python
3
+ binding generator library
4
+
5
+ Copyright (c) 2016 Wenzel Jakob <wenzel.jakob@epfl.ch>
6
+
7
+ All rights reserved. Use of this source code is governed by a
8
+ BSD-style license that can be found in the LICENSE file.
9
+ */
10
+
11
+ #pragma once
12
+
13
+ #include "detail/class.h"
14
+ #include "detail/init.h"
15
+ #include "attr.h"
16
+ #include "gil.h"
17
+ #include "gil_safe_call_once.h"
18
+ #include "options.h"
19
+ #include "typing.h"
20
+
21
+ #include <cstdlib>
22
+ #include <cstring>
23
+ #include <memory>
24
+ #include <new>
25
+ #include <string>
26
+ #include <utility>
27
+ #include <vector>
28
+
29
+ #if defined(__cpp_lib_launder) && !(defined(_MSC_VER) && (_MSC_VER < 1914))
30
+ # define PYBIND11_STD_LAUNDER std::launder
31
+ # define PYBIND11_HAS_STD_LAUNDER 1
32
+ #else
33
+ # define PYBIND11_STD_LAUNDER
34
+ # define PYBIND11_HAS_STD_LAUNDER 0
35
+ #endif
36
+ #if defined(__GNUG__) && !defined(__clang__)
37
+ # include <cxxabi.h>
38
+ #endif
39
+
40
+ PYBIND11_NAMESPACE_BEGIN(PYBIND11_NAMESPACE)
41
+
42
+ /* https://stackoverflow.com/questions/46798456/handling-gccs-noexcept-type-warning
43
+ This warning is about ABI compatibility, not code health.
44
+ It is only actually needed in a couple places, but apparently GCC 7 "generates this warning if
45
+ and only if the first template instantiation ... involves noexcept" [stackoverflow], therefore
46
+ it could get triggered from seemingly random places, depending on user code.
47
+ No other GCC version generates this warning.
48
+ */
49
+ #if defined(__GNUC__) && __GNUC__ == 7
50
+ PYBIND11_WARNING_DISABLE_GCC("-Wnoexcept-type")
51
+ #endif
52
+
53
+ PYBIND11_WARNING_DISABLE_MSVC(4127)
54
+
55
+ PYBIND11_NAMESPACE_BEGIN(detail)
56
+
57
+ inline std::string replace_newlines_and_squash(const char *text) {
58
+ const char *whitespaces = " \t\n\r\f\v";
59
+ std::string result(text);
60
+ bool previous_is_whitespace = false;
61
+
62
+ if (result.size() >= 2) {
63
+ // Do not modify string representations
64
+ char first_char = result[0];
65
+ char last_char = result[result.size() - 1];
66
+ if (first_char == last_char && first_char == '\'') {
67
+ return result;
68
+ }
69
+ }
70
+ result.clear();
71
+
72
+ // Replace characters in whitespaces array with spaces and squash consecutive spaces
73
+ while (*text != '\0') {
74
+ if (std::strchr(whitespaces, *text)) {
75
+ if (!previous_is_whitespace) {
76
+ result += ' ';
77
+ previous_is_whitespace = true;
78
+ }
79
+ } else {
80
+ result += *text;
81
+ previous_is_whitespace = false;
82
+ }
83
+ ++text;
84
+ }
85
+
86
+ // Strip leading and trailing whitespaces
87
+ const size_t str_begin = result.find_first_not_of(whitespaces);
88
+ if (str_begin == std::string::npos) {
89
+ return "";
90
+ }
91
+
92
+ const size_t str_end = result.find_last_not_of(whitespaces);
93
+ const size_t str_range = str_end - str_begin + 1;
94
+
95
+ return result.substr(str_begin, str_range);
96
+ }
97
+
98
+ // Apply all the extensions translators from a list
99
+ // Return true if one of the translators completed without raising an exception
100
+ // itself. Return of false indicates that if there are other translators
101
+ // available, they should be tried.
102
+ inline bool apply_exception_translators(std::forward_list<ExceptionTranslator> &translators) {
103
+ auto last_exception = std::current_exception();
104
+
105
+ for (auto &translator : translators) {
106
+ try {
107
+ translator(last_exception);
108
+ return true;
109
+ } catch (...) {
110
+ last_exception = std::current_exception();
111
+ }
112
+ }
113
+ return false;
114
+ }
115
+
116
+ #if defined(_MSC_VER)
117
+ # define PYBIND11_COMPAT_STRDUP _strdup
118
+ #else
119
+ # define PYBIND11_COMPAT_STRDUP strdup
120
+ #endif
121
+
122
+ PYBIND11_NAMESPACE_END(detail)
123
+
124
+ /// Wraps an arbitrary C++ function/method/lambda function/.. into a callable Python object
125
+ class cpp_function : public function {
126
+ public:
127
+ cpp_function() = default;
128
+ // NOLINTNEXTLINE(google-explicit-constructor)
129
+ cpp_function(std::nullptr_t) {}
130
+ cpp_function(std::nullptr_t, const is_setter &) {}
131
+
132
+ /// Construct a cpp_function from a vanilla function pointer
133
+ template <typename Return, typename... Args, typename... Extra>
134
+ // NOLINTNEXTLINE(google-explicit-constructor)
135
+ cpp_function(Return (*f)(Args...), const Extra &...extra) {
136
+ initialize(f, f, extra...);
137
+ }
138
+
139
+ /// Construct a cpp_function from a lambda function (possibly with internal state)
140
+ template <typename Func,
141
+ typename... Extra,
142
+ typename = detail::enable_if_t<detail::is_lambda<Func>::value>>
143
+ // NOLINTNEXTLINE(google-explicit-constructor)
144
+ cpp_function(Func &&f, const Extra &...extra) {
145
+ initialize(
146
+ std::forward<Func>(f), (detail::function_signature_t<Func> *) nullptr, extra...);
147
+ }
148
+
149
+ /// Construct a cpp_function from a class method (non-const, no ref-qualifier)
150
+ template <typename Return, typename Class, typename... Arg, typename... Extra>
151
+ // NOLINTNEXTLINE(google-explicit-constructor)
152
+ cpp_function(Return (Class::*f)(Arg...), const Extra &...extra) {
153
+ initialize(
154
+ [f](Class *c, Arg... args) -> Return { return (c->*f)(std::forward<Arg>(args)...); },
155
+ (Return(*)(Class *, Arg...)) nullptr,
156
+ extra...);
157
+ }
158
+
159
+ /// Construct a cpp_function from a class method (non-const, lvalue ref-qualifier)
160
+ /// A copy of the overload for non-const functions without explicit ref-qualifier
161
+ /// but with an added `&`.
162
+ template <typename Return, typename Class, typename... Arg, typename... Extra>
163
+ // NOLINTNEXTLINE(google-explicit-constructor)
164
+ cpp_function(Return (Class::*f)(Arg...) &, const Extra &...extra) {
165
+ initialize(
166
+ [f](Class *c, Arg... args) -> Return { return (c->*f)(std::forward<Arg>(args)...); },
167
+ (Return(*)(Class *, Arg...)) nullptr,
168
+ extra...);
169
+ }
170
+
171
+ /// Construct a cpp_function from a class method (const, no ref-qualifier)
172
+ template <typename Return, typename Class, typename... Arg, typename... Extra>
173
+ // NOLINTNEXTLINE(google-explicit-constructor)
174
+ cpp_function(Return (Class::*f)(Arg...) const, const Extra &...extra) {
175
+ initialize([f](const Class *c,
176
+ Arg... args) -> Return { return (c->*f)(std::forward<Arg>(args)...); },
177
+ (Return(*)(const Class *, Arg...)) nullptr,
178
+ extra...);
179
+ }
180
+
181
+ /// Construct a cpp_function from a class method (const, lvalue ref-qualifier)
182
+ /// A copy of the overload for const functions without explicit ref-qualifier
183
+ /// but with an added `&`.
184
+ template <typename Return, typename Class, typename... Arg, typename... Extra>
185
+ // NOLINTNEXTLINE(google-explicit-constructor)
186
+ cpp_function(Return (Class::*f)(Arg...) const &, const Extra &...extra) {
187
+ initialize([f](const Class *c,
188
+ Arg... args) -> Return { return (c->*f)(std::forward<Arg>(args)...); },
189
+ (Return(*)(const Class *, Arg...)) nullptr,
190
+ extra...);
191
+ }
192
+
193
+ /// Return the function name
194
+ object name() const { return attr("__name__"); }
195
+
196
+ protected:
197
+ struct InitializingFunctionRecordDeleter {
198
+ // `destruct(function_record, false)`: `initialize_generic` copies strings and
199
+ // takes care of cleaning up in case of exceptions. So pass `false` to `free_strings`.
200
+ void operator()(detail::function_record *rec) { destruct(rec, false); }
201
+ };
202
+ using unique_function_record
203
+ = std::unique_ptr<detail::function_record, InitializingFunctionRecordDeleter>;
204
+
205
+ /// Space optimization: don't inline this frequently instantiated fragment
206
+ PYBIND11_NOINLINE unique_function_record make_function_record() {
207
+ return unique_function_record(new detail::function_record());
208
+ }
209
+
210
+ /// Special internal constructor for functors, lambda functions, etc.
211
+ template <typename Func, typename Return, typename... Args, typename... Extra>
212
+ void initialize(Func &&f, Return (*)(Args...), const Extra &...extra) {
213
+ using namespace detail;
214
+ struct capture {
215
+ remove_reference_t<Func> f;
216
+ };
217
+
218
+ /* Store the function including any extra state it might have (e.g. a lambda capture
219
+ * object) */
220
+ // The unique_ptr makes sure nothing is leaked in case of an exception.
221
+ auto unique_rec = make_function_record();
222
+ auto *rec = unique_rec.get();
223
+
224
+ /* Store the capture object directly in the function record if there is enough space */
225
+ if (sizeof(capture) <= sizeof(rec->data)) {
226
+ /* Without these pragmas, GCC warns that there might not be
227
+ enough space to use the placement new operator. However, the
228
+ 'if' statement above ensures that this is the case. */
229
+ PYBIND11_WARNING_PUSH
230
+
231
+ #if defined(__GNUG__) && __GNUC__ >= 6
232
+ PYBIND11_WARNING_DISABLE_GCC("-Wplacement-new")
233
+ #endif
234
+
235
+ new ((capture *) &rec->data) capture{std::forward<Func>(f)};
236
+
237
+ #if !PYBIND11_HAS_STD_LAUNDER
238
+ PYBIND11_WARNING_DISABLE_GCC("-Wstrict-aliasing")
239
+ #endif
240
+
241
+ // UB without std::launder, but without breaking ABI and/or
242
+ // a significant refactoring it's "impossible" to solve.
243
+ if (!std::is_trivially_destructible<capture>::value) {
244
+ rec->free_data = [](function_record *r) {
245
+ auto data = PYBIND11_STD_LAUNDER((capture *) &r->data);
246
+ (void) data;
247
+ data->~capture();
248
+ };
249
+ }
250
+ PYBIND11_WARNING_POP
251
+ } else {
252
+ rec->data[0] = new capture{std::forward<Func>(f)};
253
+ rec->free_data = [](function_record *r) { delete ((capture *) r->data[0]); };
254
+ }
255
+
256
+ /* Type casters for the function arguments and return value */
257
+ using cast_in = argument_loader<Args...>;
258
+ using cast_out
259
+ = make_caster<conditional_t<std::is_void<Return>::value, void_type, Return>>;
260
+
261
+ static_assert(
262
+ expected_num_args<Extra...>(
263
+ sizeof...(Args), cast_in::args_pos >= 0, cast_in::has_kwargs),
264
+ "The number of argument annotations does not match the number of function arguments");
265
+
266
+ /* Dispatch code which converts function arguments and performs the actual function call */
267
+ rec->impl = [](function_call &call) -> handle {
268
+ cast_in args_converter;
269
+
270
+ /* Try to cast the function arguments into the C++ domain */
271
+ if (!args_converter.load_args(call)) {
272
+ return PYBIND11_TRY_NEXT_OVERLOAD;
273
+ }
274
+
275
+ /* Invoke call policy pre-call hook */
276
+ process_attributes<Extra...>::precall(call);
277
+
278
+ /* Get a pointer to the capture object */
279
+ const auto *data = (sizeof(capture) <= sizeof(call.func.data) ? &call.func.data
280
+ : call.func.data[0]);
281
+ auto *cap = const_cast<capture *>(reinterpret_cast<const capture *>(data));
282
+
283
+ /* Override policy for rvalues -- usually to enforce rvp::move on an rvalue */
284
+ return_value_policy policy
285
+ = return_value_policy_override<Return>::policy(call.func.policy);
286
+
287
+ /* Function scope guard -- defaults to the compile-to-nothing `void_type` */
288
+ using Guard = extract_guard_t<Extra...>;
289
+
290
+ /* Perform the function call */
291
+ handle result;
292
+ if (call.func.is_setter) {
293
+ (void) std::move(args_converter).template call<Return, Guard>(cap->f);
294
+ result = none().release();
295
+ } else {
296
+ result = cast_out::cast(
297
+ std::move(args_converter).template call<Return, Guard>(cap->f),
298
+ policy,
299
+ call.parent);
300
+ }
301
+
302
+ /* Invoke call policy post-call hook */
303
+ process_attributes<Extra...>::postcall(call, result);
304
+
305
+ return result;
306
+ };
307
+
308
+ rec->nargs_pos = cast_in::args_pos >= 0
309
+ ? static_cast<std::uint16_t>(cast_in::args_pos)
310
+ : sizeof...(Args) - cast_in::has_kwargs; // Will get reduced more if
311
+ // we have a kw_only
312
+ rec->has_args = cast_in::args_pos >= 0;
313
+ rec->has_kwargs = cast_in::has_kwargs;
314
+
315
+ /* Process any user-provided function attributes */
316
+ process_attributes<Extra...>::init(extra..., rec);
317
+
318
+ {
319
+ constexpr bool has_kw_only_args = any_of<std::is_same<kw_only, Extra>...>::value,
320
+ has_pos_only_args = any_of<std::is_same<pos_only, Extra>...>::value,
321
+ has_arg_annotations = any_of<is_keyword<Extra>...>::value;
322
+ static_assert(has_arg_annotations || !has_kw_only_args,
323
+ "py::kw_only requires the use of argument annotations");
324
+ static_assert(has_arg_annotations || !has_pos_only_args,
325
+ "py::pos_only requires the use of argument annotations (for docstrings "
326
+ "and aligning the annotations to the argument)");
327
+
328
+ static_assert(constexpr_sum(is_kw_only<Extra>::value...) <= 1,
329
+ "py::kw_only may be specified only once");
330
+ static_assert(constexpr_sum(is_pos_only<Extra>::value...) <= 1,
331
+ "py::pos_only may be specified only once");
332
+ constexpr auto kw_only_pos = constexpr_first<is_kw_only, Extra...>();
333
+ constexpr auto pos_only_pos = constexpr_first<is_pos_only, Extra...>();
334
+ static_assert(!(has_kw_only_args && has_pos_only_args) || pos_only_pos < kw_only_pos,
335
+ "py::pos_only must come before py::kw_only");
336
+ }
337
+
338
+ /* Generate a readable signature describing the function's arguments and return
339
+ value types */
340
+ static constexpr auto signature
341
+ = const_name("(") + cast_in::arg_names + const_name(") -> ") + cast_out::name;
342
+ PYBIND11_DESCR_CONSTEXPR auto types = decltype(signature)::types();
343
+
344
+ /* Register the function with Python from generic (non-templated) code */
345
+ // Pass on the ownership over the `unique_rec` to `initialize_generic`. `rec` stays valid.
346
+ initialize_generic(std::move(unique_rec), signature.text, types.data(), sizeof...(Args));
347
+
348
+ /* Stash some additional information used by an important optimization in 'functional.h' */
349
+ using FunctionType = Return (*)(Args...);
350
+ constexpr bool is_function_ptr
351
+ = std::is_convertible<Func, FunctionType>::value && sizeof(capture) == sizeof(void *);
352
+ if (is_function_ptr) {
353
+ rec->is_stateless = true;
354
+ rec->data[1]
355
+ = const_cast<void *>(reinterpret_cast<const void *>(&typeid(FunctionType)));
356
+ }
357
+ }
358
+
359
+ // Utility class that keeps track of all duplicated strings, and cleans them up in its
360
+ // destructor, unless they are released. Basically a RAII-solution to deal with exceptions
361
+ // along the way.
362
+ class strdup_guard {
363
+ public:
364
+ strdup_guard() = default;
365
+ strdup_guard(const strdup_guard &) = delete;
366
+ strdup_guard &operator=(const strdup_guard &) = delete;
367
+
368
+ ~strdup_guard() {
369
+ for (auto *s : strings) {
370
+ std::free(s);
371
+ }
372
+ }
373
+ char *operator()(const char *s) {
374
+ auto *t = PYBIND11_COMPAT_STRDUP(s);
375
+ strings.push_back(t);
376
+ return t;
377
+ }
378
+ void release() { strings.clear(); }
379
+
380
+ private:
381
+ std::vector<char *> strings;
382
+ };
383
+
384
+ /// Register a function call with Python (generic non-templated code goes here)
385
+ void initialize_generic(unique_function_record &&unique_rec,
386
+ const char *text,
387
+ const std::type_info *const *types,
388
+ size_t args) {
389
+ // Do NOT receive `unique_rec` by value. If this function fails to move out the unique_ptr,
390
+ // we do not want this to destruct the pointer. `initialize` (the caller) still relies on
391
+ // the pointee being alive after this call. Only move out if a `capsule` is going to keep
392
+ // it alive.
393
+ auto *rec = unique_rec.get();
394
+
395
+ // Keep track of strdup'ed strings, and clean them up as long as the function's capsule
396
+ // has not taken ownership yet (when `unique_rec.release()` is called).
397
+ // Note: This cannot easily be fixed by a `unique_ptr` with custom deleter, because the
398
+ // strings are only referenced before strdup'ing. So only *after* the following block could
399
+ // `destruct` safely be called, but even then, `repr` could still throw in the middle of
400
+ // copying all strings.
401
+ strdup_guard guarded_strdup;
402
+
403
+ /* Create copies of all referenced C-style strings */
404
+ rec->name = guarded_strdup(rec->name ? rec->name : "");
405
+ if (rec->doc) {
406
+ rec->doc = guarded_strdup(rec->doc);
407
+ }
408
+ for (auto &a : rec->args) {
409
+ if (a.name) {
410
+ a.name = guarded_strdup(a.name);
411
+ }
412
+ if (a.descr) {
413
+ a.descr = guarded_strdup(a.descr);
414
+ } else if (a.value) {
415
+ a.descr = guarded_strdup(repr(a.value).cast<std::string>().c_str());
416
+ }
417
+ }
418
+
419
+ rec->is_constructor = (std::strcmp(rec->name, "__init__") == 0)
420
+ || (std::strcmp(rec->name, "__setstate__") == 0);
421
+
422
+ #if defined(PYBIND11_DETAILED_ERROR_MESSAGES) && !defined(PYBIND11_DISABLE_NEW_STYLE_INIT_WARNING)
423
+ if (rec->is_constructor && !rec->is_new_style_constructor) {
424
+ const auto class_name
425
+ = detail::get_fully_qualified_tp_name((PyTypeObject *) rec->scope.ptr());
426
+ const auto func_name = std::string(rec->name);
427
+ PyErr_WarnEx(PyExc_FutureWarning,
428
+ ("pybind11-bound class '" + class_name
429
+ + "' is using an old-style "
430
+ "placement-new '"
431
+ + func_name
432
+ + "' which has been deprecated. See "
433
+ "the upgrade guide in pybind11's docs. This message is only visible "
434
+ "when compiled in debug mode.")
435
+ .c_str(),
436
+ 0);
437
+ }
438
+ #endif
439
+
440
+ /* Generate a proper function signature */
441
+ std::string signature;
442
+ size_t type_index = 0, arg_index = 0;
443
+ bool is_starred = false;
444
+ for (const auto *pc = text; *pc != '\0'; ++pc) {
445
+ const auto c = *pc;
446
+
447
+ if (c == '{') {
448
+ // Write arg name for everything except *args and **kwargs.
449
+ is_starred = *(pc + 1) == '*';
450
+ if (is_starred) {
451
+ continue;
452
+ }
453
+ // Separator for keyword-only arguments, placed before the kw
454
+ // arguments start (unless we are already putting an *args)
455
+ if (!rec->has_args && arg_index == rec->nargs_pos) {
456
+ signature += "*, ";
457
+ }
458
+ if (arg_index < rec->args.size() && rec->args[arg_index].name) {
459
+ signature += rec->args[arg_index].name;
460
+ } else if (arg_index == 0 && rec->is_method) {
461
+ signature += "self";
462
+ } else {
463
+ signature += "arg" + std::to_string(arg_index - (rec->is_method ? 1 : 0));
464
+ }
465
+ signature += ": ";
466
+ } else if (c == '}') {
467
+ // Write default value if available.
468
+ if (!is_starred && arg_index < rec->args.size() && rec->args[arg_index].descr) {
469
+ signature += " = ";
470
+ signature += detail::replace_newlines_and_squash(rec->args[arg_index].descr);
471
+ }
472
+ // Separator for positional-only arguments (placed after the
473
+ // argument, rather than before like *
474
+ if (rec->nargs_pos_only > 0 && (arg_index + 1) == rec->nargs_pos_only) {
475
+ signature += ", /";
476
+ }
477
+ if (!is_starred) {
478
+ arg_index++;
479
+ }
480
+ } else if (c == '%') {
481
+ const std::type_info *t = types[type_index++];
482
+ if (!t) {
483
+ pybind11_fail("Internal error while parsing type signature (1)");
484
+ }
485
+ if (auto *tinfo = detail::get_type_info(*t)) {
486
+ handle th((PyObject *) tinfo->type);
487
+ signature += th.attr("__module__").cast<std::string>() + "."
488
+ + th.attr("__qualname__").cast<std::string>();
489
+ } else if (rec->is_new_style_constructor && arg_index == 0) {
490
+ // A new-style `__init__` takes `self` as `value_and_holder`.
491
+ // Rewrite it to the proper class type.
492
+ signature += rec->scope.attr("__module__").cast<std::string>() + "."
493
+ + rec->scope.attr("__qualname__").cast<std::string>();
494
+ } else {
495
+ signature += detail::quote_cpp_type_name(detail::clean_type_id(t->name()));
496
+ }
497
+ } else {
498
+ signature += c;
499
+ }
500
+ }
501
+
502
+ if (arg_index != args - rec->has_args - rec->has_kwargs || types[type_index] != nullptr) {
503
+ pybind11_fail("Internal error while parsing type signature (2)");
504
+ }
505
+
506
+ rec->signature = guarded_strdup(signature.c_str());
507
+ rec->args.shrink_to_fit();
508
+ rec->nargs = (std::uint16_t) args;
509
+
510
+ if (rec->sibling && PYBIND11_INSTANCE_METHOD_CHECK(rec->sibling.ptr())) {
511
+ rec->sibling = PYBIND11_INSTANCE_METHOD_GET_FUNCTION(rec->sibling.ptr());
512
+ }
513
+
514
+ detail::function_record *chain = nullptr, *chain_start = rec;
515
+ if (rec->sibling) {
516
+ if (PyCFunction_Check(rec->sibling.ptr())) {
517
+ auto *self = PyCFunction_GET_SELF(rec->sibling.ptr());
518
+ if (!isinstance<capsule>(self)) {
519
+ chain = nullptr;
520
+ } else {
521
+ auto rec_capsule = reinterpret_borrow<capsule>(self);
522
+ if (detail::is_function_record_capsule(rec_capsule)) {
523
+ chain = rec_capsule.get_pointer<detail::function_record>();
524
+ /* Never append a method to an overload chain of a parent class;
525
+ instead, hide the parent's overloads in this case */
526
+ if (!chain->scope.is(rec->scope)) {
527
+ chain = nullptr;
528
+ }
529
+ } else {
530
+ chain = nullptr;
531
+ }
532
+ }
533
+ }
534
+ // Don't trigger for things like the default __init__, which are wrapper_descriptors
535
+ // that we are intentionally replacing
536
+ else if (!rec->sibling.is_none() && rec->name[0] != '_') {
537
+ pybind11_fail("Cannot overload existing non-function object \""
538
+ + std::string(rec->name) + "\" with a function of the same name");
539
+ }
540
+ }
541
+
542
+ if (!chain) {
543
+ /* No existing overload was found, create a new function object */
544
+ rec->def = new PyMethodDef();
545
+ std::memset(rec->def, 0, sizeof(PyMethodDef));
546
+ rec->def->ml_name = rec->name;
547
+ rec->def->ml_meth
548
+ = reinterpret_cast<PyCFunction>(reinterpret_cast<void (*)()>(dispatcher));
549
+ rec->def->ml_flags = METH_VARARGS | METH_KEYWORDS;
550
+
551
+ capsule rec_capsule(unique_rec.release(),
552
+ detail::get_function_record_capsule_name(),
553
+ [](void *ptr) { destruct((detail::function_record *) ptr); });
554
+ guarded_strdup.release();
555
+
556
+ object scope_module;
557
+ if (rec->scope) {
558
+ if (hasattr(rec->scope, "__module__")) {
559
+ scope_module = rec->scope.attr("__module__");
560
+ } else if (hasattr(rec->scope, "__name__")) {
561
+ scope_module = rec->scope.attr("__name__");
562
+ }
563
+ }
564
+
565
+ m_ptr = PyCFunction_NewEx(rec->def, rec_capsule.ptr(), scope_module.ptr());
566
+ if (!m_ptr) {
567
+ pybind11_fail("cpp_function::cpp_function(): Could not allocate function object");
568
+ }
569
+ } else {
570
+ /* Append at the beginning or end of the overload chain */
571
+ m_ptr = rec->sibling.ptr();
572
+ inc_ref();
573
+ if (chain->is_method != rec->is_method) {
574
+ pybind11_fail(
575
+ "overloading a method with both static and instance methods is not supported; "
576
+ #if !defined(PYBIND11_DETAILED_ERROR_MESSAGES)
577
+ "#define PYBIND11_DETAILED_ERROR_MESSAGES or compile in debug mode for more "
578
+ "details"
579
+ #else
580
+ "error while attempting to bind "
581
+ + std::string(rec->is_method ? "instance" : "static") + " method "
582
+ + std::string(pybind11::str(rec->scope.attr("__name__"))) + "."
583
+ + std::string(rec->name) + signature
584
+ #endif
585
+ );
586
+ }
587
+
588
+ if (rec->prepend) {
589
+ // Beginning of chain; we need to replace the capsule's current head-of-the-chain
590
+ // pointer with this one, then make this one point to the previous head of the
591
+ // chain.
592
+ chain_start = rec;
593
+ rec->next = chain;
594
+ auto rec_capsule
595
+ = reinterpret_borrow<capsule>(((PyCFunctionObject *) m_ptr)->m_self);
596
+ rec_capsule.set_pointer(unique_rec.release());
597
+ guarded_strdup.release();
598
+ } else {
599
+ // Or end of chain (normal behavior)
600
+ chain_start = chain;
601
+ while (chain->next) {
602
+ chain = chain->next;
603
+ }
604
+ chain->next = unique_rec.release();
605
+ guarded_strdup.release();
606
+ }
607
+ }
608
+
609
+ std::string signatures;
610
+ int index = 0;
611
+ /* Create a nice pydoc rec including all signatures and
612
+ docstrings of the functions in the overload chain */
613
+ if (chain && options::show_function_signatures()) {
614
+ // First a generic signature
615
+ signatures += rec->name;
616
+ signatures += "(*args, **kwargs)\n";
617
+ signatures += "Overloaded function.\n\n";
618
+ }
619
+ // Then specific overload signatures
620
+ bool first_user_def = true;
621
+ for (auto *it = chain_start; it != nullptr; it = it->next) {
622
+ if (options::show_function_signatures()) {
623
+ if (index > 0) {
624
+ signatures += '\n';
625
+ }
626
+ if (chain) {
627
+ signatures += std::to_string(++index) + ". ";
628
+ }
629
+ signatures += rec->name;
630
+ signatures += it->signature;
631
+ signatures += '\n';
632
+ }
633
+ if (it->doc && it->doc[0] != '\0' && options::show_user_defined_docstrings()) {
634
+ // If we're appending another docstring, and aren't printing function signatures,
635
+ // we need to append a newline first:
636
+ if (!options::show_function_signatures()) {
637
+ if (first_user_def) {
638
+ first_user_def = false;
639
+ } else {
640
+ signatures += '\n';
641
+ }
642
+ }
643
+ if (options::show_function_signatures()) {
644
+ signatures += '\n';
645
+ }
646
+ signatures += it->doc;
647
+ if (options::show_function_signatures()) {
648
+ signatures += '\n';
649
+ }
650
+ }
651
+ }
652
+
653
+ /* Install docstring */
654
+ auto *func = (PyCFunctionObject *) m_ptr;
655
+ std::free(const_cast<char *>(func->m_ml->ml_doc));
656
+ // Install docstring if it's non-empty (when at least one option is enabled)
657
+ func->m_ml->ml_doc
658
+ = signatures.empty() ? nullptr : PYBIND11_COMPAT_STRDUP(signatures.c_str());
659
+
660
+ if (rec->is_method) {
661
+ m_ptr = PYBIND11_INSTANCE_METHOD_NEW(m_ptr, rec->scope.ptr());
662
+ if (!m_ptr) {
663
+ pybind11_fail(
664
+ "cpp_function::cpp_function(): Could not allocate instance method object");
665
+ }
666
+ Py_DECREF(func);
667
+ }
668
+ }
669
+
670
+ /// When a cpp_function is GCed, release any memory allocated by pybind11
671
+ static void destruct(detail::function_record *rec, bool free_strings = true) {
672
+ // If on Python 3.9, check the interpreter "MICRO" (patch) version.
673
+ // If this is running on 3.9.0, we have to work around a bug.
674
+ #if !defined(PYPY_VERSION) && PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION == 9
675
+ static bool is_zero = Py_GetVersion()[4] == '0';
676
+ #endif
677
+
678
+ while (rec) {
679
+ detail::function_record *next = rec->next;
680
+ if (rec->free_data) {
681
+ rec->free_data(rec);
682
+ }
683
+ // During initialization, these strings might not have been copied yet,
684
+ // so they cannot be freed. Once the function has been created, they can.
685
+ // Check `make_function_record` for more details.
686
+ if (free_strings) {
687
+ std::free((char *) rec->name);
688
+ std::free((char *) rec->doc);
689
+ std::free((char *) rec->signature);
690
+ for (auto &arg : rec->args) {
691
+ std::free(const_cast<char *>(arg.name));
692
+ std::free(const_cast<char *>(arg.descr));
693
+ }
694
+ }
695
+ for (auto &arg : rec->args) {
696
+ arg.value.dec_ref();
697
+ }
698
+ if (rec->def) {
699
+ std::free(const_cast<char *>(rec->def->ml_doc));
700
+ // Python 3.9.0 decref's these in the wrong order; rec->def
701
+ // If loaded on 3.9.0, let these leak (use Python 3.9.1 at runtime to fix)
702
+ // See https://github.com/python/cpython/pull/22670
703
+ #if !defined(PYPY_VERSION) && PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION == 9
704
+ if (!is_zero) {
705
+ delete rec->def;
706
+ }
707
+ #else
708
+ delete rec->def;
709
+ #endif
710
+ }
711
+ delete rec;
712
+ rec = next;
713
+ }
714
+ }
715
+
716
+ /// Main dispatch logic for calls to functions bound using pybind11
717
+ static PyObject *dispatcher(PyObject *self, PyObject *args_in, PyObject *kwargs_in) {
718
+ using namespace detail;
719
+ assert(isinstance<capsule>(self));
720
+
721
+ /* Iterator over the list of potentially admissible overloads */
722
+ const function_record *overloads = reinterpret_cast<function_record *>(
723
+ PyCapsule_GetPointer(self, get_function_record_capsule_name())),
724
+ *current_overload = overloads;
725
+ assert(overloads != nullptr);
726
+
727
+ /* Need to know how many arguments + keyword arguments there are to pick the right
728
+ overload */
729
+ const auto n_args_in = (size_t) PyTuple_GET_SIZE(args_in);
730
+
731
+ handle parent = n_args_in > 0 ? PyTuple_GET_ITEM(args_in, 0) : nullptr,
732
+ result = PYBIND11_TRY_NEXT_OVERLOAD;
733
+
734
+ auto self_value_and_holder = value_and_holder();
735
+ if (overloads->is_constructor) {
736
+ if (!parent
737
+ || !PyObject_TypeCheck(parent.ptr(), (PyTypeObject *) overloads->scope.ptr())) {
738
+ set_error(PyExc_TypeError,
739
+ "__init__(self, ...) called with invalid or missing `self` argument");
740
+ return nullptr;
741
+ }
742
+
743
+ auto *const tinfo = get_type_info((PyTypeObject *) overloads->scope.ptr());
744
+ auto *const pi = reinterpret_cast<instance *>(parent.ptr());
745
+ self_value_and_holder = pi->get_value_and_holder(tinfo, true);
746
+
747
+ // If this value is already registered it must mean __init__ is invoked multiple times;
748
+ // we really can't support that in C++, so just ignore the second __init__.
749
+ if (self_value_and_holder.instance_registered()) {
750
+ return none().release().ptr();
751
+ }
752
+ }
753
+
754
+ try {
755
+ // We do this in two passes: in the first pass, we load arguments with `convert=false`;
756
+ // in the second, we allow conversion (except for arguments with an explicit
757
+ // py::arg().noconvert()). This lets us prefer calls without conversion, with
758
+ // conversion as a fallback.
759
+ std::vector<function_call> second_pass;
760
+
761
+ // However, if there are no overloads, we can just skip the no-convert pass entirely
762
+ const bool overloaded
763
+ = current_overload != nullptr && current_overload->next != nullptr;
764
+
765
+ for (; current_overload != nullptr; current_overload = current_overload->next) {
766
+
767
+ /* For each overload:
768
+ 1. Copy all positional arguments we were given, also checking to make sure that
769
+ named positional arguments weren't *also* specified via kwarg.
770
+ 2. If we weren't given enough, try to make up the omitted ones by checking
771
+ whether they were provided by a kwarg matching the `py::arg("name")` name. If
772
+ so, use it (and remove it from kwargs); if not, see if the function binding
773
+ provided a default that we can use.
774
+ 3. Ensure that either all keyword arguments were "consumed", or that the
775
+ function takes a kwargs argument to accept unconsumed kwargs.
776
+ 4. Any positional arguments still left get put into a tuple (for args), and any
777
+ leftover kwargs get put into a dict.
778
+ 5. Pack everything into a vector; if we have py::args or py::kwargs, they are an
779
+ extra tuple or dict at the end of the positional arguments.
780
+ 6. Call the function call dispatcher (function_record::impl)
781
+
782
+ If one of these fail, move on to the next overload and keep trying until we get
783
+ a result other than PYBIND11_TRY_NEXT_OVERLOAD.
784
+ */
785
+
786
+ const function_record &func = *current_overload;
787
+ size_t num_args = func.nargs; // Number of positional arguments that we need
788
+ if (func.has_args) {
789
+ --num_args; // (but don't count py::args
790
+ }
791
+ if (func.has_kwargs) {
792
+ --num_args; // or py::kwargs)
793
+ }
794
+ size_t pos_args = func.nargs_pos;
795
+
796
+ if (!func.has_args && n_args_in > pos_args) {
797
+ continue; // Too many positional arguments for this overload
798
+ }
799
+
800
+ if (n_args_in < pos_args && func.args.size() < pos_args) {
801
+ continue; // Not enough positional arguments given, and not enough defaults to
802
+ // fill in the blanks
803
+ }
804
+
805
+ function_call call(func, parent);
806
+
807
+ // Protect std::min with parentheses
808
+ size_t args_to_copy = (std::min)(pos_args, n_args_in);
809
+ size_t args_copied = 0;
810
+
811
+ // 0. Inject new-style `self` argument
812
+ if (func.is_new_style_constructor) {
813
+ // The `value` may have been preallocated by an old-style `__init__`
814
+ // if it was a preceding candidate for overload resolution.
815
+ if (self_value_and_holder) {
816
+ self_value_and_holder.type->dealloc(self_value_and_holder);
817
+ }
818
+
819
+ call.init_self = PyTuple_GET_ITEM(args_in, 0);
820
+ call.args.emplace_back(reinterpret_cast<PyObject *>(&self_value_and_holder));
821
+ call.args_convert.push_back(false);
822
+ ++args_copied;
823
+ }
824
+
825
+ // 1. Copy any position arguments given.
826
+ bool bad_arg = false;
827
+ for (; args_copied < args_to_copy; ++args_copied) {
828
+ const argument_record *arg_rec
829
+ = args_copied < func.args.size() ? &func.args[args_copied] : nullptr;
830
+ if (kwargs_in && arg_rec && arg_rec->name
831
+ && dict_getitemstring(kwargs_in, arg_rec->name)) {
832
+ bad_arg = true;
833
+ break;
834
+ }
835
+
836
+ handle arg(PyTuple_GET_ITEM(args_in, args_copied));
837
+ if (arg_rec && !arg_rec->none && arg.is_none()) {
838
+ bad_arg = true;
839
+ break;
840
+ }
841
+ call.args.push_back(arg);
842
+ call.args_convert.push_back(arg_rec ? arg_rec->convert : true);
843
+ }
844
+ if (bad_arg) {
845
+ continue; // Maybe it was meant for another overload (issue #688)
846
+ }
847
+
848
+ // Keep track of how many position args we copied out in case we need to come back
849
+ // to copy the rest into a py::args argument.
850
+ size_t positional_args_copied = args_copied;
851
+
852
+ // We'll need to copy this if we steal some kwargs for defaults
853
+ dict kwargs = reinterpret_borrow<dict>(kwargs_in);
854
+
855
+ // 1.5. Fill in any missing pos_only args from defaults if they exist
856
+ if (args_copied < func.nargs_pos_only) {
857
+ for (; args_copied < func.nargs_pos_only; ++args_copied) {
858
+ const auto &arg_rec = func.args[args_copied];
859
+ handle value;
860
+
861
+ if (arg_rec.value) {
862
+ value = arg_rec.value;
863
+ }
864
+ if (value) {
865
+ call.args.push_back(value);
866
+ call.args_convert.push_back(arg_rec.convert);
867
+ } else {
868
+ break;
869
+ }
870
+ }
871
+
872
+ if (args_copied < func.nargs_pos_only) {
873
+ continue; // Not enough defaults to fill the positional arguments
874
+ }
875
+ }
876
+
877
+ // 2. Check kwargs and, failing that, defaults that may help complete the list
878
+ if (args_copied < num_args) {
879
+ bool copied_kwargs = false;
880
+
881
+ for (; args_copied < num_args; ++args_copied) {
882
+ const auto &arg_rec = func.args[args_copied];
883
+
884
+ handle value;
885
+ if (kwargs_in && arg_rec.name) {
886
+ value = dict_getitemstring(kwargs.ptr(), arg_rec.name);
887
+ }
888
+
889
+ if (value) {
890
+ // Consume a kwargs value
891
+ if (!copied_kwargs) {
892
+ kwargs = reinterpret_steal<dict>(PyDict_Copy(kwargs.ptr()));
893
+ copied_kwargs = true;
894
+ }
895
+ if (PyDict_DelItemString(kwargs.ptr(), arg_rec.name) == -1) {
896
+ throw error_already_set();
897
+ }
898
+ } else if (arg_rec.value) {
899
+ value = arg_rec.value;
900
+ }
901
+
902
+ if (!arg_rec.none && value.is_none()) {
903
+ break;
904
+ }
905
+
906
+ if (value) {
907
+ // If we're at the py::args index then first insert a stub for it to be
908
+ // replaced later
909
+ if (func.has_args && call.args.size() == func.nargs_pos) {
910
+ call.args.push_back(none());
911
+ }
912
+
913
+ call.args.push_back(value);
914
+ call.args_convert.push_back(arg_rec.convert);
915
+ } else {
916
+ break;
917
+ }
918
+ }
919
+
920
+ if (args_copied < num_args) {
921
+ continue; // Not enough arguments, defaults, or kwargs to fill the
922
+ // positional arguments
923
+ }
924
+ }
925
+
926
+ // 3. Check everything was consumed (unless we have a kwargs arg)
927
+ if (kwargs && !kwargs.empty() && !func.has_kwargs) {
928
+ continue; // Unconsumed kwargs, but no py::kwargs argument to accept them
929
+ }
930
+
931
+ // 4a. If we have a py::args argument, create a new tuple with leftovers
932
+ if (func.has_args) {
933
+ tuple extra_args;
934
+ if (args_to_copy == 0) {
935
+ // We didn't copy out any position arguments from the args_in tuple, so we
936
+ // can reuse it directly without copying:
937
+ extra_args = reinterpret_borrow<tuple>(args_in);
938
+ } else if (positional_args_copied >= n_args_in) {
939
+ extra_args = tuple(0);
940
+ } else {
941
+ size_t args_size = n_args_in - positional_args_copied;
942
+ extra_args = tuple(args_size);
943
+ for (size_t i = 0; i < args_size; ++i) {
944
+ extra_args[i] = PyTuple_GET_ITEM(args_in, positional_args_copied + i);
945
+ }
946
+ }
947
+ if (call.args.size() <= func.nargs_pos) {
948
+ call.args.push_back(extra_args);
949
+ } else {
950
+ call.args[func.nargs_pos] = extra_args;
951
+ }
952
+ call.args_convert.push_back(false);
953
+ call.args_ref = std::move(extra_args);
954
+ }
955
+
956
+ // 4b. If we have a py::kwargs, pass on any remaining kwargs
957
+ if (func.has_kwargs) {
958
+ if (!kwargs.ptr()) {
959
+ kwargs = dict(); // If we didn't get one, send an empty one
960
+ }
961
+ call.args.push_back(kwargs);
962
+ call.args_convert.push_back(false);
963
+ call.kwargs_ref = std::move(kwargs);
964
+ }
965
+
966
+ // 5. Put everything in a vector. Not technically step 5, we've been building it
967
+ // in `call.args` all along.
968
+ #if defined(PYBIND11_DETAILED_ERROR_MESSAGES)
969
+ if (call.args.size() != func.nargs || call.args_convert.size() != func.nargs) {
970
+ pybind11_fail("Internal error: function call dispatcher inserted wrong number "
971
+ "of arguments!");
972
+ }
973
+ #endif
974
+
975
+ std::vector<bool> second_pass_convert;
976
+ if (overloaded) {
977
+ // We're in the first no-convert pass, so swap out the conversion flags for a
978
+ // set of all-false flags. If the call fails, we'll swap the flags back in for
979
+ // the conversion-allowed call below.
980
+ second_pass_convert.resize(func.nargs, false);
981
+ call.args_convert.swap(second_pass_convert);
982
+ }
983
+
984
+ // 6. Call the function.
985
+ try {
986
+ loader_life_support guard{};
987
+ result = func.impl(call);
988
+ } catch (reference_cast_error &) {
989
+ result = PYBIND11_TRY_NEXT_OVERLOAD;
990
+ }
991
+
992
+ if (result.ptr() != PYBIND11_TRY_NEXT_OVERLOAD) {
993
+ break;
994
+ }
995
+
996
+ if (overloaded) {
997
+ // The (overloaded) call failed; if the call has at least one argument that
998
+ // permits conversion (i.e. it hasn't been explicitly specified `.noconvert()`)
999
+ // then add this call to the list of second pass overloads to try.
1000
+ for (size_t i = func.is_method ? 1 : 0; i < pos_args; i++) {
1001
+ if (second_pass_convert[i]) {
1002
+ // Found one: swap the converting flags back in and store the call for
1003
+ // the second pass.
1004
+ call.args_convert.swap(second_pass_convert);
1005
+ second_pass.push_back(std::move(call));
1006
+ break;
1007
+ }
1008
+ }
1009
+ }
1010
+ }
1011
+
1012
+ if (overloaded && !second_pass.empty() && result.ptr() == PYBIND11_TRY_NEXT_OVERLOAD) {
1013
+ // The no-conversion pass finished without success, try again with conversion
1014
+ // allowed
1015
+ for (auto &call : second_pass) {
1016
+ try {
1017
+ loader_life_support guard{};
1018
+ result = call.func.impl(call);
1019
+ } catch (reference_cast_error &) {
1020
+ result = PYBIND11_TRY_NEXT_OVERLOAD;
1021
+ }
1022
+
1023
+ if (result.ptr() != PYBIND11_TRY_NEXT_OVERLOAD) {
1024
+ // The error reporting logic below expects 'current_overload' to be valid,
1025
+ // as it would be if we'd encountered this failure in the first-pass loop.
1026
+ if (!result) {
1027
+ current_overload = &call.func;
1028
+ }
1029
+ break;
1030
+ }
1031
+ }
1032
+ }
1033
+ } catch (error_already_set &e) {
1034
+ e.restore();
1035
+ return nullptr;
1036
+ #ifdef __GLIBCXX__
1037
+ } catch (abi::__forced_unwind &) {
1038
+ throw;
1039
+ #endif
1040
+ } catch (...) {
1041
+ /* When an exception is caught, give each registered exception
1042
+ translator a chance to translate it to a Python exception. First
1043
+ all module-local translators will be tried in reverse order of
1044
+ registration. If none of the module-locale translators handle
1045
+ the exception (or there are no module-locale translators) then
1046
+ the global translators will be tried, also in reverse order of
1047
+ registration.
1048
+
1049
+ A translator may choose to do one of the following:
1050
+
1051
+ - catch the exception and call py::set_error()
1052
+ to set a standard (or custom) Python exception, or
1053
+ - do nothing and let the exception fall through to the next translator, or
1054
+ - delegate translation to the next translator by throwing a new type of exception.
1055
+ */
1056
+
1057
+ bool handled = with_internals([&](internals &internals) {
1058
+ auto &local_exception_translators
1059
+ = get_local_internals().registered_exception_translators;
1060
+ if (detail::apply_exception_translators(local_exception_translators)) {
1061
+ return true;
1062
+ }
1063
+ auto &exception_translators = internals.registered_exception_translators;
1064
+ if (detail::apply_exception_translators(exception_translators)) {
1065
+ return true;
1066
+ }
1067
+ return false;
1068
+ });
1069
+
1070
+ if (handled) {
1071
+ return nullptr;
1072
+ }
1073
+
1074
+ set_error(PyExc_SystemError, "Exception escaped from default exception translator!");
1075
+ return nullptr;
1076
+ }
1077
+
1078
+ auto append_note_if_missing_header_is_suspected = [](std::string &msg) {
1079
+ if (msg.find("std::") != std::string::npos) {
1080
+ msg += "\n\n"
1081
+ "Did you forget to `#include <pybind11/stl.h>`? Or <pybind11/complex.h>,\n"
1082
+ "<pybind11/functional.h>, <pybind11/chrono.h>, etc. Some automatic\n"
1083
+ "conversions are optional and require extra headers to be included\n"
1084
+ "when compiling your pybind11 module.";
1085
+ }
1086
+ };
1087
+
1088
+ if (result.ptr() == PYBIND11_TRY_NEXT_OVERLOAD) {
1089
+ if (overloads->is_operator) {
1090
+ return handle(Py_NotImplemented).inc_ref().ptr();
1091
+ }
1092
+
1093
+ std::string msg = std::string(overloads->name) + "(): incompatible "
1094
+ + std::string(overloads->is_constructor ? "constructor" : "function")
1095
+ + " arguments. The following argument types are supported:\n";
1096
+
1097
+ int ctr = 0;
1098
+ for (const function_record *it2 = overloads; it2 != nullptr; it2 = it2->next) {
1099
+ msg += " " + std::to_string(++ctr) + ". ";
1100
+
1101
+ bool wrote_sig = false;
1102
+ if (overloads->is_constructor) {
1103
+ // For a constructor, rewrite `(self: Object, arg0, ...) -> NoneType` as
1104
+ // `Object(arg0, ...)`
1105
+ std::string sig = it2->signature;
1106
+ size_t start = sig.find('(') + 7; // skip "(self: "
1107
+ if (start < sig.size()) {
1108
+ // End at the , for the next argument
1109
+ size_t end = sig.find(", "), next = end + 2;
1110
+ size_t ret = sig.rfind(" -> ");
1111
+ // Or the ), if there is no comma:
1112
+ if (end >= sig.size()) {
1113
+ next = end = sig.find(')');
1114
+ }
1115
+ if (start < end && next < sig.size()) {
1116
+ msg.append(sig, start, end - start);
1117
+ msg += '(';
1118
+ msg.append(sig, next, ret - next);
1119
+ wrote_sig = true;
1120
+ }
1121
+ }
1122
+ }
1123
+ if (!wrote_sig) {
1124
+ msg += it2->signature;
1125
+ }
1126
+
1127
+ msg += '\n';
1128
+ }
1129
+ msg += "\nInvoked with: ";
1130
+ auto args_ = reinterpret_borrow<tuple>(args_in);
1131
+ bool some_args = false;
1132
+ for (size_t ti = overloads->is_constructor ? 1 : 0; ti < args_.size(); ++ti) {
1133
+ if (!some_args) {
1134
+ some_args = true;
1135
+ } else {
1136
+ msg += ", ";
1137
+ }
1138
+ try {
1139
+ msg += pybind11::repr(args_[ti]);
1140
+ } catch (const error_already_set &) {
1141
+ msg += "<repr raised Error>";
1142
+ }
1143
+ }
1144
+ if (kwargs_in) {
1145
+ auto kwargs = reinterpret_borrow<dict>(kwargs_in);
1146
+ if (!kwargs.empty()) {
1147
+ if (some_args) {
1148
+ msg += "; ";
1149
+ }
1150
+ msg += "kwargs: ";
1151
+ bool first = true;
1152
+ for (const auto &kwarg : kwargs) {
1153
+ if (first) {
1154
+ first = false;
1155
+ } else {
1156
+ msg += ", ";
1157
+ }
1158
+ msg += pybind11::str("{}=").format(kwarg.first);
1159
+ try {
1160
+ msg += pybind11::repr(kwarg.second);
1161
+ } catch (const error_already_set &) {
1162
+ msg += "<repr raised Error>";
1163
+ }
1164
+ }
1165
+ }
1166
+ }
1167
+
1168
+ append_note_if_missing_header_is_suspected(msg);
1169
+ // Attach additional error info to the exception if supported
1170
+ if (PyErr_Occurred()) {
1171
+ // #HelpAppreciated: unit test coverage for this branch.
1172
+ raise_from(PyExc_TypeError, msg.c_str());
1173
+ return nullptr;
1174
+ }
1175
+ set_error(PyExc_TypeError, msg.c_str());
1176
+ return nullptr;
1177
+ }
1178
+ if (!result) {
1179
+ std::string msg = "Unable to convert function return value to a "
1180
+ "Python type! The signature was\n\t";
1181
+ assert(current_overload != nullptr);
1182
+ msg += current_overload->signature;
1183
+ append_note_if_missing_header_is_suspected(msg);
1184
+ // Attach additional error info to the exception if supported
1185
+ if (PyErr_Occurred()) {
1186
+ raise_from(PyExc_TypeError, msg.c_str());
1187
+ return nullptr;
1188
+ }
1189
+ set_error(PyExc_TypeError, msg.c_str());
1190
+ return nullptr;
1191
+ }
1192
+ if (overloads->is_constructor && !self_value_and_holder.holder_constructed()) {
1193
+ auto *pi = reinterpret_cast<instance *>(parent.ptr());
1194
+ self_value_and_holder.type->init_instance(pi, nullptr);
1195
+ }
1196
+ return result.ptr();
1197
+ }
1198
+ };
1199
+
1200
+ PYBIND11_NAMESPACE_BEGIN(detail)
1201
+
1202
+ template <>
1203
+ struct handle_type_name<cpp_function> {
1204
+ static constexpr auto name = const_name("Callable");
1205
+ };
1206
+
1207
+ PYBIND11_NAMESPACE_END(detail)
1208
+
1209
+ // Use to activate Py_MOD_GIL_NOT_USED.
1210
+ class mod_gil_not_used {
1211
+ public:
1212
+ explicit mod_gil_not_used(bool flag = true) : flag_(flag) {}
1213
+ bool flag() const { return flag_; }
1214
+
1215
+ private:
1216
+ bool flag_;
1217
+ };
1218
+
1219
+ /// Wrapper for Python extension modules
1220
+ class module_ : public object {
1221
+ public:
1222
+ PYBIND11_OBJECT_DEFAULT(module_, object, PyModule_Check)
1223
+
1224
+ /// Create a new top-level Python module with the given name and docstring
1225
+ PYBIND11_DEPRECATED("Use PYBIND11_MODULE or module_::create_extension_module instead")
1226
+ explicit module_(const char *name, const char *doc = nullptr) {
1227
+ *this = create_extension_module(name, doc, new PyModuleDef());
1228
+ }
1229
+
1230
+ /** \rst
1231
+ Create Python binding for a new function within the module scope. ``Func``
1232
+ can be a plain C++ function, a function pointer, or a lambda function. For
1233
+ details on the ``Extra&& ... extra`` argument, see section :ref:`extras`.
1234
+ \endrst */
1235
+ template <typename Func, typename... Extra>
1236
+ module_ &def(const char *name_, Func &&f, const Extra &...extra) {
1237
+ cpp_function func(std::forward<Func>(f),
1238
+ name(name_),
1239
+ scope(*this),
1240
+ sibling(getattr(*this, name_, none())),
1241
+ extra...);
1242
+ // NB: allow overwriting here because cpp_function sets up a chain with the intention of
1243
+ // overwriting (and has already checked internally that it isn't overwriting
1244
+ // non-functions).
1245
+ add_object(name_, func, true /* overwrite */);
1246
+ return *this;
1247
+ }
1248
+
1249
+ /** \rst
1250
+ Create and return a new Python submodule with the given name and docstring.
1251
+ This also works recursively, i.e.
1252
+
1253
+ .. code-block:: cpp
1254
+
1255
+ py::module_ m("example", "pybind11 example plugin");
1256
+ py::module_ m2 = m.def_submodule("sub", "A submodule of 'example'");
1257
+ py::module_ m3 = m2.def_submodule("subsub", "A submodule of 'example.sub'");
1258
+ \endrst */
1259
+ module_ def_submodule(const char *name, const char *doc = nullptr) {
1260
+ const char *this_name = PyModule_GetName(m_ptr);
1261
+ if (this_name == nullptr) {
1262
+ throw error_already_set();
1263
+ }
1264
+ std::string full_name = std::string(this_name) + '.' + name;
1265
+ handle submodule = PyImport_AddModule(full_name.c_str());
1266
+ if (!submodule) {
1267
+ throw error_already_set();
1268
+ }
1269
+ auto result = reinterpret_borrow<module_>(submodule);
1270
+ if (doc && options::show_user_defined_docstrings()) {
1271
+ result.attr("__doc__") = pybind11::str(doc);
1272
+ }
1273
+ attr(name) = result;
1274
+ return result;
1275
+ }
1276
+
1277
+ /// Import and return a module or throws `error_already_set`.
1278
+ static module_ import(const char *name) {
1279
+ PyObject *obj = PyImport_ImportModule(name);
1280
+ if (!obj) {
1281
+ throw error_already_set();
1282
+ }
1283
+ return reinterpret_steal<module_>(obj);
1284
+ }
1285
+
1286
+ /// Reload the module or throws `error_already_set`.
1287
+ void reload() {
1288
+ PyObject *obj = PyImport_ReloadModule(ptr());
1289
+ if (!obj) {
1290
+ throw error_already_set();
1291
+ }
1292
+ *this = reinterpret_steal<module_>(obj);
1293
+ }
1294
+
1295
+ /** \rst
1296
+ Adds an object to the module using the given name. Throws if an object with the given name
1297
+ already exists.
1298
+
1299
+ ``overwrite`` should almost always be false: attempting to overwrite objects that pybind11
1300
+ has established will, in most cases, break things.
1301
+ \endrst */
1302
+ PYBIND11_NOINLINE void add_object(const char *name, handle obj, bool overwrite = false) {
1303
+ if (!overwrite && hasattr(*this, name)) {
1304
+ pybind11_fail(
1305
+ "Error during initialization: multiple incompatible definitions with name \""
1306
+ + std::string(name) + "\"");
1307
+ }
1308
+
1309
+ PyModule_AddObject(ptr(), name, obj.inc_ref().ptr() /* steals a reference */);
1310
+ }
1311
+
1312
+ using module_def = PyModuleDef; // TODO: Can this be removed (it was needed only for Python 2)?
1313
+
1314
+ /** \rst
1315
+ Create a new top-level module that can be used as the main module of a C extension.
1316
+
1317
+ ``def`` should point to a statically allocated module_def.
1318
+ \endrst */
1319
+ static module_ create_extension_module(const char *name,
1320
+ const char *doc,
1321
+ module_def *def,
1322
+ mod_gil_not_used gil_not_used
1323
+ = mod_gil_not_used(false)) {
1324
+ // module_def is PyModuleDef
1325
+ // Placement new (not an allocation).
1326
+ def = new (def)
1327
+ PyModuleDef{/* m_base */ PyModuleDef_HEAD_INIT,
1328
+ /* m_name */ name,
1329
+ /* m_doc */ options::show_user_defined_docstrings() ? doc : nullptr,
1330
+ /* m_size */ -1,
1331
+ /* m_methods */ nullptr,
1332
+ /* m_slots */ nullptr,
1333
+ /* m_traverse */ nullptr,
1334
+ /* m_clear */ nullptr,
1335
+ /* m_free */ nullptr};
1336
+ auto *m = PyModule_Create(def);
1337
+ if (m == nullptr) {
1338
+ if (PyErr_Occurred()) {
1339
+ throw error_already_set();
1340
+ }
1341
+ pybind11_fail("Internal error in module_::create_extension_module()");
1342
+ }
1343
+ if (gil_not_used.flag()) {
1344
+ #ifdef Py_GIL_DISABLED
1345
+ PyUnstable_Module_SetGIL(m, Py_MOD_GIL_NOT_USED);
1346
+ #endif
1347
+ }
1348
+ // TODO: Should be reinterpret_steal for Python 3, but Python also steals it again when
1349
+ // returned from PyInit_...
1350
+ // For Python 2, reinterpret_borrow was correct.
1351
+ return reinterpret_borrow<module_>(m);
1352
+ }
1353
+ };
1354
+
1355
+ PYBIND11_NAMESPACE_BEGIN(detail)
1356
+
1357
+ template <>
1358
+ struct handle_type_name<module_> {
1359
+ static constexpr auto name = const_name("module");
1360
+ };
1361
+
1362
+ PYBIND11_NAMESPACE_END(detail)
1363
+
1364
+ // When inside a namespace (or anywhere as long as it's not the first item on a line),
1365
+ // C++20 allows "module" to be used. This is provided for backward compatibility, and for
1366
+ // simplicity, if someone wants to use py::module for example, that is perfectly safe.
1367
+ using module = module_;
1368
+
1369
+ /// \ingroup python_builtins
1370
+ /// Return a dictionary representing the global variables in the current execution frame,
1371
+ /// or ``__main__.__dict__`` if there is no frame (usually when the interpreter is embedded).
1372
+ inline dict globals() {
1373
+ #if PY_VERSION_HEX >= 0x030d0000
1374
+ PyObject *p = PyEval_GetFrameGlobals();
1375
+ return p ? reinterpret_steal<dict>(p)
1376
+ : reinterpret_borrow<dict>(module_::import("__main__").attr("__dict__").ptr());
1377
+ #else
1378
+ PyObject *p = PyEval_GetGlobals();
1379
+ return reinterpret_borrow<dict>(p ? p : module_::import("__main__").attr("__dict__").ptr());
1380
+ #endif
1381
+ }
1382
+
1383
+ template <typename... Args, typename = detail::enable_if_t<args_are_all_keyword_or_ds<Args...>()>>
1384
+ PYBIND11_DEPRECATED("make_simple_namespace should be replaced with "
1385
+ "py::module_::import(\"types\").attr(\"SimpleNamespace\") ")
1386
+ object make_simple_namespace(Args &&...args_) {
1387
+ return module_::import("types").attr("SimpleNamespace")(std::forward<Args>(args_)...);
1388
+ }
1389
+
1390
+ PYBIND11_NAMESPACE_BEGIN(detail)
1391
+ /// Generic support for creating new Python heap types
1392
+ class generic_type : public object {
1393
+ public:
1394
+ PYBIND11_OBJECT_DEFAULT(generic_type, object, PyType_Check)
1395
+ protected:
1396
+ void initialize(const type_record &rec) {
1397
+ if (rec.scope && hasattr(rec.scope, "__dict__")
1398
+ && rec.scope.attr("__dict__").contains(rec.name)) {
1399
+ pybind11_fail("generic_type: cannot initialize type \"" + std::string(rec.name)
1400
+ + "\": an object with that name is already defined");
1401
+ }
1402
+
1403
+ if ((rec.module_local ? get_local_type_info(*rec.type) : get_global_type_info(*rec.type))
1404
+ != nullptr) {
1405
+ pybind11_fail("generic_type: type \"" + std::string(rec.name)
1406
+ + "\" is already registered!");
1407
+ }
1408
+
1409
+ m_ptr = make_new_python_type(rec);
1410
+
1411
+ /* Register supplemental type information in C++ dict */
1412
+ auto *tinfo = new detail::type_info();
1413
+ tinfo->type = (PyTypeObject *) m_ptr;
1414
+ tinfo->cpptype = rec.type;
1415
+ tinfo->type_size = rec.type_size;
1416
+ tinfo->type_align = rec.type_align;
1417
+ tinfo->operator_new = rec.operator_new;
1418
+ tinfo->holder_size_in_ptrs = size_in_ptrs(rec.holder_size);
1419
+ tinfo->init_instance = rec.init_instance;
1420
+ tinfo->dealloc = rec.dealloc;
1421
+ tinfo->simple_type = true;
1422
+ tinfo->simple_ancestors = true;
1423
+ tinfo->default_holder = rec.default_holder;
1424
+ tinfo->module_local = rec.module_local;
1425
+
1426
+ with_internals([&](internals &internals) {
1427
+ auto tindex = std::type_index(*rec.type);
1428
+ tinfo->direct_conversions = &internals.direct_conversions[tindex];
1429
+ if (rec.module_local) {
1430
+ get_local_internals().registered_types_cpp[tindex] = tinfo;
1431
+ } else {
1432
+ internals.registered_types_cpp[tindex] = tinfo;
1433
+ }
1434
+ internals.registered_types_py[(PyTypeObject *) m_ptr] = {tinfo};
1435
+ });
1436
+
1437
+ if (rec.bases.size() > 1 || rec.multiple_inheritance) {
1438
+ mark_parents_nonsimple(tinfo->type);
1439
+ tinfo->simple_ancestors = false;
1440
+ } else if (rec.bases.size() == 1) {
1441
+ auto *parent_tinfo = get_type_info((PyTypeObject *) rec.bases[0].ptr());
1442
+ assert(parent_tinfo != nullptr);
1443
+ bool parent_simple_ancestors = parent_tinfo->simple_ancestors;
1444
+ tinfo->simple_ancestors = parent_simple_ancestors;
1445
+ // The parent can no longer be a simple type if it has MI and has a child
1446
+ parent_tinfo->simple_type = parent_tinfo->simple_type && parent_simple_ancestors;
1447
+ }
1448
+
1449
+ if (rec.module_local) {
1450
+ // Stash the local typeinfo and loader so that external modules can access it.
1451
+ tinfo->module_local_load = &type_caster_generic::local_load;
1452
+ setattr(m_ptr, PYBIND11_MODULE_LOCAL_ID, capsule(tinfo));
1453
+ }
1454
+ }
1455
+
1456
+ /// Helper function which tags all parents of a type using mult. inheritance
1457
+ void mark_parents_nonsimple(PyTypeObject *value) {
1458
+ auto t = reinterpret_borrow<tuple>(value->tp_bases);
1459
+ for (handle h : t) {
1460
+ auto *tinfo2 = get_type_info((PyTypeObject *) h.ptr());
1461
+ if (tinfo2) {
1462
+ tinfo2->simple_type = false;
1463
+ }
1464
+ mark_parents_nonsimple((PyTypeObject *) h.ptr());
1465
+ }
1466
+ }
1467
+
1468
+ void install_buffer_funcs(buffer_info *(*get_buffer)(PyObject *, void *),
1469
+ void *get_buffer_data) {
1470
+ auto *type = (PyHeapTypeObject *) m_ptr;
1471
+ auto *tinfo = detail::get_type_info(&type->ht_type);
1472
+
1473
+ if (!type->ht_type.tp_as_buffer) {
1474
+ pybind11_fail("To be able to register buffer protocol support for the type '"
1475
+ + get_fully_qualified_tp_name(tinfo->type)
1476
+ + "' the associated class<>(..) invocation must "
1477
+ "include the pybind11::buffer_protocol() annotation!");
1478
+ }
1479
+
1480
+ tinfo->get_buffer = get_buffer;
1481
+ tinfo->get_buffer_data = get_buffer_data;
1482
+ }
1483
+
1484
+ // rec_func must be set for either fget or fset.
1485
+ void def_property_static_impl(const char *name,
1486
+ handle fget,
1487
+ handle fset,
1488
+ detail::function_record *rec_func) {
1489
+ const auto is_static = (rec_func != nullptr) && !(rec_func->is_method && rec_func->scope);
1490
+ const auto has_doc = (rec_func != nullptr) && (rec_func->doc != nullptr)
1491
+ && pybind11::options::show_user_defined_docstrings();
1492
+ auto property = handle(
1493
+ (PyObject *) (is_static ? get_internals().static_property_type : &PyProperty_Type));
1494
+ attr(name) = property(fget.ptr() ? fget : none(),
1495
+ fset.ptr() ? fset : none(),
1496
+ /*deleter*/ none(),
1497
+ pybind11::str(has_doc ? rec_func->doc : ""));
1498
+ }
1499
+ };
1500
+
1501
+ /// Set the pointer to operator new if it exists. The cast is needed because it can be overloaded.
1502
+ template <typename T,
1503
+ typename = void_t<decltype(static_cast<void *(*) (size_t)>(T::operator new))>>
1504
+ void set_operator_new(type_record *r) {
1505
+ r->operator_new = &T::operator new;
1506
+ }
1507
+
1508
+ template <typename>
1509
+ void set_operator_new(...) {}
1510
+
1511
+ template <typename T, typename SFINAE = void>
1512
+ struct has_operator_delete : std::false_type {};
1513
+ template <typename T>
1514
+ struct has_operator_delete<T, void_t<decltype(static_cast<void (*)(void *)>(T::operator delete))>>
1515
+ : std::true_type {};
1516
+ template <typename T, typename SFINAE = void>
1517
+ struct has_operator_delete_size : std::false_type {};
1518
+ template <typename T>
1519
+ struct has_operator_delete_size<
1520
+ T,
1521
+ void_t<decltype(static_cast<void (*)(void *, size_t)>(T::operator delete))>> : std::true_type {
1522
+ };
1523
+ /// Call class-specific delete if it exists or global otherwise. Can also be an overload set.
1524
+ template <typename T, enable_if_t<has_operator_delete<T>::value, int> = 0>
1525
+ void call_operator_delete(T *p, size_t, size_t) {
1526
+ T::operator delete(p);
1527
+ }
1528
+ template <typename T,
1529
+ enable_if_t<!has_operator_delete<T>::value && has_operator_delete_size<T>::value, int>
1530
+ = 0>
1531
+ void call_operator_delete(T *p, size_t s, size_t) {
1532
+ T::operator delete(p, s);
1533
+ }
1534
+
1535
+ inline void call_operator_delete(void *p, size_t s, size_t a) {
1536
+ (void) s;
1537
+ (void) a;
1538
+ #if defined(__cpp_aligned_new) && (!defined(_MSC_VER) || _MSC_VER >= 1912)
1539
+ if (a > __STDCPP_DEFAULT_NEW_ALIGNMENT__) {
1540
+ # ifdef __cpp_sized_deallocation
1541
+ ::operator delete(p, s, std::align_val_t(a));
1542
+ # else
1543
+ ::operator delete(p, std::align_val_t(a));
1544
+ # endif
1545
+ return;
1546
+ }
1547
+ #endif
1548
+ #ifdef __cpp_sized_deallocation
1549
+ ::operator delete(p, s);
1550
+ #else
1551
+ ::operator delete(p);
1552
+ #endif
1553
+ }
1554
+
1555
+ inline void add_class_method(object &cls, const char *name_, const cpp_function &cf) {
1556
+ cls.attr(cf.name()) = cf;
1557
+ if (std::strcmp(name_, "__eq__") == 0 && !cls.attr("__dict__").contains("__hash__")) {
1558
+ cls.attr("__hash__") = none();
1559
+ }
1560
+ }
1561
+
1562
+ PYBIND11_NAMESPACE_END(detail)
1563
+
1564
+ /// Given a pointer to a member function, cast it to its `Derived` version.
1565
+ /// Forward everything else unchanged.
1566
+ template <typename /*Derived*/, typename F>
1567
+ auto method_adaptor(F &&f) -> decltype(std::forward<F>(f)) {
1568
+ return std::forward<F>(f);
1569
+ }
1570
+
1571
+ template <typename Derived, typename Return, typename Class, typename... Args>
1572
+ auto method_adaptor(Return (Class::*pmf)(Args...)) -> Return (Derived::*)(Args...) {
1573
+ static_assert(
1574
+ detail::is_accessible_base_of<Class, Derived>::value,
1575
+ "Cannot bind an inaccessible base class method; use a lambda definition instead");
1576
+ return pmf;
1577
+ }
1578
+
1579
+ template <typename Derived, typename Return, typename Class, typename... Args>
1580
+ auto method_adaptor(Return (Class::*pmf)(Args...) const) -> Return (Derived::*)(Args...) const {
1581
+ static_assert(
1582
+ detail::is_accessible_base_of<Class, Derived>::value,
1583
+ "Cannot bind an inaccessible base class method; use a lambda definition instead");
1584
+ return pmf;
1585
+ }
1586
+
1587
+ template <typename type_, typename... options>
1588
+ class class_ : public detail::generic_type {
1589
+ template <typename T>
1590
+ using is_holder = detail::is_holder_type<type_, T>;
1591
+ template <typename T>
1592
+ using is_subtype = detail::is_strict_base_of<type_, T>;
1593
+ template <typename T>
1594
+ using is_base = detail::is_strict_base_of<T, type_>;
1595
+ // struct instead of using here to help MSVC:
1596
+ template <typename T>
1597
+ struct is_valid_class_option : detail::any_of<is_holder<T>, is_subtype<T>, is_base<T>> {};
1598
+
1599
+ public:
1600
+ using type = type_;
1601
+ using type_alias = detail::exactly_one_t<is_subtype, void, options...>;
1602
+ constexpr static bool has_alias = !std::is_void<type_alias>::value;
1603
+ using holder_type = detail::exactly_one_t<is_holder, std::unique_ptr<type>, options...>;
1604
+
1605
+ static_assert(detail::all_of<is_valid_class_option<options>...>::value,
1606
+ "Unknown/invalid class_ template parameters provided");
1607
+
1608
+ static_assert(!has_alias || std::is_polymorphic<type>::value,
1609
+ "Cannot use an alias class with a non-polymorphic type");
1610
+
1611
+ PYBIND11_OBJECT(class_, generic_type, PyType_Check)
1612
+
1613
+ template <typename... Extra>
1614
+ class_(handle scope, const char *name, const Extra &...extra) {
1615
+ using namespace detail;
1616
+
1617
+ // MI can only be specified via class_ template options, not constructor parameters
1618
+ static_assert(
1619
+ none_of<is_pyobject<Extra>...>::value || // no base class arguments, or:
1620
+ (constexpr_sum(is_pyobject<Extra>::value...) == 1 && // Exactly one base
1621
+ constexpr_sum(is_base<options>::value...) == 0 && // no template option bases
1622
+ // no multiple_inheritance attr
1623
+ none_of<std::is_same<multiple_inheritance, Extra>...>::value),
1624
+ "Error: multiple inheritance bases must be specified via class_ template options");
1625
+
1626
+ type_record record;
1627
+ record.scope = scope;
1628
+ record.name = name;
1629
+ record.type = &typeid(type);
1630
+ record.type_size = sizeof(conditional_t<has_alias, type_alias, type>);
1631
+ record.type_align = alignof(conditional_t<has_alias, type_alias, type> &);
1632
+ record.holder_size = sizeof(holder_type);
1633
+ record.init_instance = init_instance;
1634
+ record.dealloc = dealloc;
1635
+ record.default_holder = detail::is_instantiation<std::unique_ptr, holder_type>::value;
1636
+
1637
+ set_operator_new<type>(&record);
1638
+
1639
+ /* Register base classes specified via template arguments to class_, if any */
1640
+ PYBIND11_EXPAND_SIDE_EFFECTS(add_base<options>(record));
1641
+
1642
+ /* Process optional arguments, if any */
1643
+ process_attributes<Extra...>::init(extra..., &record);
1644
+
1645
+ generic_type::initialize(record);
1646
+
1647
+ if (has_alias) {
1648
+ with_internals([&](internals &internals) {
1649
+ auto &instances = record.module_local ? get_local_internals().registered_types_cpp
1650
+ : internals.registered_types_cpp;
1651
+ instances[std::type_index(typeid(type_alias))]
1652
+ = instances[std::type_index(typeid(type))];
1653
+ });
1654
+ }
1655
+ }
1656
+
1657
+ template <typename Base, detail::enable_if_t<is_base<Base>::value, int> = 0>
1658
+ static void add_base(detail::type_record &rec) {
1659
+ rec.add_base(typeid(Base), [](void *src) -> void * {
1660
+ return static_cast<Base *>(reinterpret_cast<type *>(src));
1661
+ });
1662
+ }
1663
+
1664
+ template <typename Base, detail::enable_if_t<!is_base<Base>::value, int> = 0>
1665
+ static void add_base(detail::type_record &) {}
1666
+
1667
+ template <typename Func, typename... Extra>
1668
+ class_ &def(const char *name_, Func &&f, const Extra &...extra) {
1669
+ cpp_function cf(method_adaptor<type>(std::forward<Func>(f)),
1670
+ name(name_),
1671
+ is_method(*this),
1672
+ sibling(getattr(*this, name_, none())),
1673
+ extra...);
1674
+ add_class_method(*this, name_, cf);
1675
+ return *this;
1676
+ }
1677
+
1678
+ template <typename Func, typename... Extra>
1679
+ class_ &def_static(const char *name_, Func &&f, const Extra &...extra) {
1680
+ static_assert(!std::is_member_function_pointer<Func>::value,
1681
+ "def_static(...) called with a non-static member function pointer");
1682
+ cpp_function cf(std::forward<Func>(f),
1683
+ name(name_),
1684
+ scope(*this),
1685
+ sibling(getattr(*this, name_, none())),
1686
+ extra...);
1687
+ auto cf_name = cf.name();
1688
+ attr(std::move(cf_name)) = staticmethod(std::move(cf));
1689
+ return *this;
1690
+ }
1691
+
1692
+ template <typename T, typename... Extra, detail::enable_if_t<T::op_enable_if_hook, int> = 0>
1693
+ class_ &def(const T &op, const Extra &...extra) {
1694
+ op.execute(*this, extra...);
1695
+ return *this;
1696
+ }
1697
+
1698
+ template <typename T, typename... Extra, detail::enable_if_t<T::op_enable_if_hook, int> = 0>
1699
+ class_ &def_cast(const T &op, const Extra &...extra) {
1700
+ op.execute_cast(*this, extra...);
1701
+ return *this;
1702
+ }
1703
+
1704
+ template <typename... Args, typename... Extra>
1705
+ class_ &def(const detail::initimpl::constructor<Args...> &init, const Extra &...extra) {
1706
+ PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(init);
1707
+ init.execute(*this, extra...);
1708
+ return *this;
1709
+ }
1710
+
1711
+ template <typename... Args, typename... Extra>
1712
+ class_ &def(const detail::initimpl::alias_constructor<Args...> &init, const Extra &...extra) {
1713
+ PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(init);
1714
+ init.execute(*this, extra...);
1715
+ return *this;
1716
+ }
1717
+
1718
+ template <typename... Args, typename... Extra>
1719
+ class_ &def(detail::initimpl::factory<Args...> &&init, const Extra &...extra) {
1720
+ std::move(init).execute(*this, extra...);
1721
+ return *this;
1722
+ }
1723
+
1724
+ template <typename... Args, typename... Extra>
1725
+ class_ &def(detail::initimpl::pickle_factory<Args...> &&pf, const Extra &...extra) {
1726
+ std::move(pf).execute(*this, extra...);
1727
+ return *this;
1728
+ }
1729
+
1730
+ template <typename Func>
1731
+ class_ &def_buffer(Func &&func) {
1732
+ struct capture {
1733
+ Func func;
1734
+ };
1735
+ auto *ptr = new capture{std::forward<Func>(func)};
1736
+ install_buffer_funcs(
1737
+ [](PyObject *obj, void *ptr) -> buffer_info * {
1738
+ detail::make_caster<type> caster;
1739
+ if (!caster.load(obj, false)) {
1740
+ return nullptr;
1741
+ }
1742
+ return new buffer_info(((capture *) ptr)->func(std::move(caster)));
1743
+ },
1744
+ ptr);
1745
+ weakref(m_ptr, cpp_function([ptr](handle wr) {
1746
+ delete ptr;
1747
+ wr.dec_ref();
1748
+ }))
1749
+ .release();
1750
+ return *this;
1751
+ }
1752
+
1753
+ template <typename Return, typename Class, typename... Args>
1754
+ class_ &def_buffer(Return (Class::*func)(Args...)) {
1755
+ return def_buffer([func](type &obj) { return (obj.*func)(); });
1756
+ }
1757
+
1758
+ template <typename Return, typename Class, typename... Args>
1759
+ class_ &def_buffer(Return (Class::*func)(Args...) const) {
1760
+ return def_buffer([func](const type &obj) { return (obj.*func)(); });
1761
+ }
1762
+
1763
+ template <typename C, typename D, typename... Extra>
1764
+ class_ &def_readwrite(const char *name, D C::*pm, const Extra &...extra) {
1765
+ static_assert(std::is_same<C, type>::value || std::is_base_of<C, type>::value,
1766
+ "def_readwrite() requires a class member (or base class member)");
1767
+ cpp_function fget([pm](const type &c) -> const D & { return c.*pm; }, is_method(*this)),
1768
+ fset([pm](type &c, const D &value) { c.*pm = value; }, is_method(*this));
1769
+ def_property(name, fget, fset, return_value_policy::reference_internal, extra...);
1770
+ return *this;
1771
+ }
1772
+
1773
+ template <typename C, typename D, typename... Extra>
1774
+ class_ &def_readonly(const char *name, const D C::*pm, const Extra &...extra) {
1775
+ static_assert(std::is_same<C, type>::value || std::is_base_of<C, type>::value,
1776
+ "def_readonly() requires a class member (or base class member)");
1777
+ cpp_function fget([pm](const type &c) -> const D & { return c.*pm; }, is_method(*this));
1778
+ def_property_readonly(name, fget, return_value_policy::reference_internal, extra...);
1779
+ return *this;
1780
+ }
1781
+
1782
+ template <typename D, typename... Extra>
1783
+ class_ &def_readwrite_static(const char *name, D *pm, const Extra &...extra) {
1784
+ cpp_function fget([pm](const object &) -> const D & { return *pm; }, scope(*this)),
1785
+ fset([pm](const object &, const D &value) { *pm = value; }, scope(*this));
1786
+ def_property_static(name, fget, fset, return_value_policy::reference, extra...);
1787
+ return *this;
1788
+ }
1789
+
1790
+ template <typename D, typename... Extra>
1791
+ class_ &def_readonly_static(const char *name, const D *pm, const Extra &...extra) {
1792
+ cpp_function fget([pm](const object &) -> const D & { return *pm; }, scope(*this));
1793
+ def_property_readonly_static(name, fget, return_value_policy::reference, extra...);
1794
+ return *this;
1795
+ }
1796
+
1797
+ /// Uses return_value_policy::reference_internal by default
1798
+ template <typename Getter, typename... Extra>
1799
+ class_ &def_property_readonly(const char *name, const Getter &fget, const Extra &...extra) {
1800
+ return def_property_readonly(name,
1801
+ cpp_function(method_adaptor<type>(fget)),
1802
+ return_value_policy::reference_internal,
1803
+ extra...);
1804
+ }
1805
+
1806
+ /// Uses cpp_function's return_value_policy by default
1807
+ template <typename... Extra>
1808
+ class_ &
1809
+ def_property_readonly(const char *name, const cpp_function &fget, const Extra &...extra) {
1810
+ return def_property(name, fget, nullptr, extra...);
1811
+ }
1812
+
1813
+ /// Uses return_value_policy::reference by default
1814
+ template <typename Getter, typename... Extra>
1815
+ class_ &
1816
+ def_property_readonly_static(const char *name, const Getter &fget, const Extra &...extra) {
1817
+ return def_property_readonly_static(
1818
+ name, cpp_function(fget), return_value_policy::reference, extra...);
1819
+ }
1820
+
1821
+ /// Uses cpp_function's return_value_policy by default
1822
+ template <typename... Extra>
1823
+ class_ &def_property_readonly_static(const char *name,
1824
+ const cpp_function &fget,
1825
+ const Extra &...extra) {
1826
+ return def_property_static(name, fget, nullptr, extra...);
1827
+ }
1828
+
1829
+ /// Uses return_value_policy::reference_internal by default
1830
+ template <typename Getter, typename Setter, typename... Extra>
1831
+ class_ &
1832
+ def_property(const char *name, const Getter &fget, const Setter &fset, const Extra &...extra) {
1833
+ return def_property(
1834
+ name, fget, cpp_function(method_adaptor<type>(fset), is_setter()), extra...);
1835
+ }
1836
+ template <typename Getter, typename... Extra>
1837
+ class_ &def_property(const char *name,
1838
+ const Getter &fget,
1839
+ const cpp_function &fset,
1840
+ const Extra &...extra) {
1841
+ return def_property(name,
1842
+ cpp_function(method_adaptor<type>(fget)),
1843
+ fset,
1844
+ return_value_policy::reference_internal,
1845
+ extra...);
1846
+ }
1847
+
1848
+ /// Uses cpp_function's return_value_policy by default
1849
+ template <typename... Extra>
1850
+ class_ &def_property(const char *name,
1851
+ const cpp_function &fget,
1852
+ const cpp_function &fset,
1853
+ const Extra &...extra) {
1854
+ return def_property_static(name, fget, fset, is_method(*this), extra...);
1855
+ }
1856
+
1857
+ /// Uses return_value_policy::reference by default
1858
+ template <typename Getter, typename... Extra>
1859
+ class_ &def_property_static(const char *name,
1860
+ const Getter &fget,
1861
+ const cpp_function &fset,
1862
+ const Extra &...extra) {
1863
+ return def_property_static(
1864
+ name, cpp_function(fget), fset, return_value_policy::reference, extra...);
1865
+ }
1866
+
1867
+ /// Uses cpp_function's return_value_policy by default
1868
+ template <typename... Extra>
1869
+ class_ &def_property_static(const char *name,
1870
+ const cpp_function &fget,
1871
+ const cpp_function &fset,
1872
+ const Extra &...extra) {
1873
+ static_assert(0 == detail::constexpr_sum(std::is_base_of<arg, Extra>::value...),
1874
+ "Argument annotations are not allowed for properties");
1875
+ auto rec_fget = get_function_record(fget), rec_fset = get_function_record(fset);
1876
+ auto *rec_active = rec_fget;
1877
+ if (rec_fget) {
1878
+ char *doc_prev = rec_fget->doc; /* 'extra' field may include a property-specific
1879
+ documentation string */
1880
+ detail::process_attributes<Extra...>::init(extra..., rec_fget);
1881
+ if (rec_fget->doc && rec_fget->doc != doc_prev) {
1882
+ std::free(doc_prev);
1883
+ rec_fget->doc = PYBIND11_COMPAT_STRDUP(rec_fget->doc);
1884
+ }
1885
+ }
1886
+ if (rec_fset) {
1887
+ char *doc_prev = rec_fset->doc;
1888
+ detail::process_attributes<Extra...>::init(extra..., rec_fset);
1889
+ if (rec_fset->doc && rec_fset->doc != doc_prev) {
1890
+ std::free(doc_prev);
1891
+ rec_fset->doc = PYBIND11_COMPAT_STRDUP(rec_fset->doc);
1892
+ }
1893
+ if (!rec_active) {
1894
+ rec_active = rec_fset;
1895
+ }
1896
+ }
1897
+ def_property_static_impl(name, fget, fset, rec_active);
1898
+ return *this;
1899
+ }
1900
+
1901
+ private:
1902
+ /// Initialize holder object, variant 1: object derives from enable_shared_from_this
1903
+ template <typename T>
1904
+ static void init_holder(detail::instance *inst,
1905
+ detail::value_and_holder &v_h,
1906
+ const holder_type * /* unused */,
1907
+ const std::enable_shared_from_this<T> * /* dummy */) {
1908
+
1909
+ auto sh = std::dynamic_pointer_cast<typename holder_type::element_type>(
1910
+ detail::try_get_shared_from_this(v_h.value_ptr<type>()));
1911
+ if (sh) {
1912
+ new (std::addressof(v_h.holder<holder_type>())) holder_type(std::move(sh));
1913
+ v_h.set_holder_constructed();
1914
+ }
1915
+
1916
+ if (!v_h.holder_constructed() && inst->owned) {
1917
+ new (std::addressof(v_h.holder<holder_type>())) holder_type(v_h.value_ptr<type>());
1918
+ v_h.set_holder_constructed();
1919
+ }
1920
+ }
1921
+
1922
+ static void init_holder_from_existing(const detail::value_and_holder &v_h,
1923
+ const holder_type *holder_ptr,
1924
+ std::true_type /*is_copy_constructible*/) {
1925
+ new (std::addressof(v_h.holder<holder_type>()))
1926
+ holder_type(*reinterpret_cast<const holder_type *>(holder_ptr));
1927
+ }
1928
+
1929
+ static void init_holder_from_existing(const detail::value_and_holder &v_h,
1930
+ const holder_type *holder_ptr,
1931
+ std::false_type /*is_copy_constructible*/) {
1932
+ new (std::addressof(v_h.holder<holder_type>()))
1933
+ holder_type(std::move(*const_cast<holder_type *>(holder_ptr)));
1934
+ }
1935
+
1936
+ /// Initialize holder object, variant 2: try to construct from existing holder object, if
1937
+ /// possible
1938
+ static void init_holder(detail::instance *inst,
1939
+ detail::value_and_holder &v_h,
1940
+ const holder_type *holder_ptr,
1941
+ const void * /* dummy -- not enable_shared_from_this<T>) */) {
1942
+ if (holder_ptr) {
1943
+ init_holder_from_existing(v_h, holder_ptr, std::is_copy_constructible<holder_type>());
1944
+ v_h.set_holder_constructed();
1945
+ } else if (detail::always_construct_holder<holder_type>::value || inst->owned) {
1946
+ new (std::addressof(v_h.holder<holder_type>())) holder_type(v_h.value_ptr<type>());
1947
+ v_h.set_holder_constructed();
1948
+ }
1949
+ }
1950
+
1951
+ /// Performs instance initialization including constructing a holder and registering the known
1952
+ /// instance. Should be called as soon as the `type` value_ptr is set for an instance. Takes
1953
+ /// an optional pointer to an existing holder to use; if not specified and the instance is
1954
+ /// `.owned`, a new holder will be constructed to manage the value pointer.
1955
+ static void init_instance(detail::instance *inst, const void *holder_ptr) {
1956
+ auto v_h = inst->get_value_and_holder(detail::get_type_info(typeid(type)));
1957
+ if (!v_h.instance_registered()) {
1958
+ register_instance(inst, v_h.value_ptr(), v_h.type);
1959
+ v_h.set_instance_registered();
1960
+ }
1961
+ init_holder(inst, v_h, (const holder_type *) holder_ptr, v_h.value_ptr<type>());
1962
+ }
1963
+
1964
+ /// Deallocates an instance; via holder, if constructed; otherwise via operator delete.
1965
+ static void dealloc(detail::value_and_holder &v_h) {
1966
+ // We could be deallocating because we are cleaning up after a Python exception.
1967
+ // If so, the Python error indicator will be set. We need to clear that before
1968
+ // running the destructor, in case the destructor code calls more Python.
1969
+ // If we don't, the Python API will exit with an exception, and pybind11 will
1970
+ // throw error_already_set from the C++ destructor which is forbidden and triggers
1971
+ // std::terminate().
1972
+ error_scope scope;
1973
+ if (v_h.holder_constructed()) {
1974
+ v_h.holder<holder_type>().~holder_type();
1975
+ v_h.set_holder_constructed(false);
1976
+ } else {
1977
+ detail::call_operator_delete(
1978
+ v_h.value_ptr<type>(), v_h.type->type_size, v_h.type->type_align);
1979
+ }
1980
+ v_h.value_ptr() = nullptr;
1981
+ }
1982
+
1983
+ static detail::function_record *get_function_record(handle h) {
1984
+ h = detail::get_function(h);
1985
+ if (!h) {
1986
+ return nullptr;
1987
+ }
1988
+
1989
+ handle func_self = PyCFunction_GET_SELF(h.ptr());
1990
+ if (!func_self) {
1991
+ throw error_already_set();
1992
+ }
1993
+ if (!isinstance<capsule>(func_self)) {
1994
+ return nullptr;
1995
+ }
1996
+ auto cap = reinterpret_borrow<capsule>(func_self);
1997
+ if (!detail::is_function_record_capsule(cap)) {
1998
+ return nullptr;
1999
+ }
2000
+ return cap.get_pointer<detail::function_record>();
2001
+ }
2002
+ };
2003
+
2004
+ /// Binds an existing constructor taking arguments Args...
2005
+ template <typename... Args>
2006
+ detail::initimpl::constructor<Args...> init() {
2007
+ return {};
2008
+ }
2009
+ /// Like `init<Args...>()`, but the instance is always constructed through the alias class (even
2010
+ /// when not inheriting on the Python side).
2011
+ template <typename... Args>
2012
+ detail::initimpl::alias_constructor<Args...> init_alias() {
2013
+ return {};
2014
+ }
2015
+
2016
+ /// Binds a factory function as a constructor
2017
+ template <typename Func, typename Ret = detail::initimpl::factory<Func>>
2018
+ Ret init(Func &&f) {
2019
+ return {std::forward<Func>(f)};
2020
+ }
2021
+
2022
+ /// Dual-argument factory function: the first function is called when no alias is needed, the
2023
+ /// second when an alias is needed (i.e. due to python-side inheritance). Arguments must be
2024
+ /// identical.
2025
+ template <typename CFunc, typename AFunc, typename Ret = detail::initimpl::factory<CFunc, AFunc>>
2026
+ Ret init(CFunc &&c, AFunc &&a) {
2027
+ return {std::forward<CFunc>(c), std::forward<AFunc>(a)};
2028
+ }
2029
+
2030
+ /// Binds pickling functions `__getstate__` and `__setstate__` and ensures that the type
2031
+ /// returned by `__getstate__` is the same as the argument accepted by `__setstate__`.
2032
+ template <typename GetState, typename SetState>
2033
+ detail::initimpl::pickle_factory<GetState, SetState> pickle(GetState &&g, SetState &&s) {
2034
+ return {std::forward<GetState>(g), std::forward<SetState>(s)};
2035
+ }
2036
+
2037
+ PYBIND11_NAMESPACE_BEGIN(detail)
2038
+
2039
+ inline str enum_name(handle arg) {
2040
+ dict entries = arg.get_type().attr("__entries");
2041
+ for (auto kv : entries) {
2042
+ if (handle(kv.second[int_(0)]).equal(arg)) {
2043
+ return pybind11::str(kv.first);
2044
+ }
2045
+ }
2046
+ return "???";
2047
+ }
2048
+
2049
+ struct enum_base {
2050
+ enum_base(const handle &base, const handle &parent) : m_base(base), m_parent(parent) {}
2051
+
2052
+ PYBIND11_NOINLINE void init(bool is_arithmetic, bool is_convertible) {
2053
+ m_base.attr("__entries") = dict();
2054
+ auto property = handle((PyObject *) &PyProperty_Type);
2055
+ auto static_property = handle((PyObject *) get_internals().static_property_type);
2056
+
2057
+ m_base.attr("__repr__") = cpp_function(
2058
+ [](const object &arg) -> str {
2059
+ handle type = type::handle_of(arg);
2060
+ object type_name = type.attr("__name__");
2061
+ return pybind11::str("<{}.{}: {}>")
2062
+ .format(std::move(type_name), enum_name(arg), int_(arg));
2063
+ },
2064
+ name("__repr__"),
2065
+ is_method(m_base));
2066
+
2067
+ m_base.attr("name") = property(cpp_function(&enum_name, name("name"), is_method(m_base)));
2068
+
2069
+ m_base.attr("__str__") = cpp_function(
2070
+ [](handle arg) -> str {
2071
+ object type_name = type::handle_of(arg).attr("__name__");
2072
+ return pybind11::str("{}.{}").format(std::move(type_name), enum_name(arg));
2073
+ },
2074
+ name("__str__"),
2075
+ is_method(m_base));
2076
+
2077
+ if (options::show_enum_members_docstring()) {
2078
+ m_base.attr("__doc__") = static_property(
2079
+ cpp_function(
2080
+ [](handle arg) -> std::string {
2081
+ std::string docstring;
2082
+ dict entries = arg.attr("__entries");
2083
+ if (((PyTypeObject *) arg.ptr())->tp_doc) {
2084
+ docstring += std::string(
2085
+ reinterpret_cast<PyTypeObject *>(arg.ptr())->tp_doc);
2086
+ docstring += "\n\n";
2087
+ }
2088
+ docstring += "Members:";
2089
+ for (auto kv : entries) {
2090
+ auto key = std::string(pybind11::str(kv.first));
2091
+ auto comment = kv.second[int_(1)];
2092
+ docstring += "\n\n ";
2093
+ docstring += key;
2094
+ if (!comment.is_none()) {
2095
+ docstring += " : ";
2096
+ docstring += pybind11::str(comment).cast<std::string>();
2097
+ }
2098
+ }
2099
+ return docstring;
2100
+ },
2101
+ name("__doc__")),
2102
+ none(),
2103
+ none(),
2104
+ "");
2105
+ }
2106
+
2107
+ m_base.attr("__members__") = static_property(cpp_function(
2108
+ [](handle arg) -> dict {
2109
+ dict entries = arg.attr("__entries"),
2110
+ m;
2111
+ for (auto kv : entries) {
2112
+ m[kv.first] = kv.second[int_(0)];
2113
+ }
2114
+ return m;
2115
+ },
2116
+ name("__members__")),
2117
+ none(),
2118
+ none(),
2119
+ "");
2120
+
2121
+ #define PYBIND11_ENUM_OP_STRICT(op, expr, strict_behavior) \
2122
+ m_base.attr(op) = cpp_function( \
2123
+ [](const object &a, const object &b) { \
2124
+ if (!type::handle_of(a).is(type::handle_of(b))) \
2125
+ strict_behavior; /* NOLINT(bugprone-macro-parentheses) */ \
2126
+ return expr; \
2127
+ }, \
2128
+ name(op), \
2129
+ is_method(m_base), \
2130
+ arg("other"))
2131
+
2132
+ #define PYBIND11_ENUM_OP_CONV(op, expr) \
2133
+ m_base.attr(op) = cpp_function( \
2134
+ [](const object &a_, const object &b_) { \
2135
+ int_ a(a_), b(b_); \
2136
+ return expr; \
2137
+ }, \
2138
+ name(op), \
2139
+ is_method(m_base), \
2140
+ arg("other"))
2141
+
2142
+ #define PYBIND11_ENUM_OP_CONV_LHS(op, expr) \
2143
+ m_base.attr(op) = cpp_function( \
2144
+ [](const object &a_, const object &b) { \
2145
+ int_ a(a_); \
2146
+ return expr; \
2147
+ }, \
2148
+ name(op), \
2149
+ is_method(m_base), \
2150
+ arg("other"))
2151
+
2152
+ if (is_convertible) {
2153
+ PYBIND11_ENUM_OP_CONV_LHS("__eq__", !b.is_none() && a.equal(b));
2154
+ PYBIND11_ENUM_OP_CONV_LHS("__ne__", b.is_none() || !a.equal(b));
2155
+
2156
+ if (is_arithmetic) {
2157
+ PYBIND11_ENUM_OP_CONV("__lt__", a < b);
2158
+ PYBIND11_ENUM_OP_CONV("__gt__", a > b);
2159
+ PYBIND11_ENUM_OP_CONV("__le__", a <= b);
2160
+ PYBIND11_ENUM_OP_CONV("__ge__", a >= b);
2161
+ PYBIND11_ENUM_OP_CONV("__and__", a & b);
2162
+ PYBIND11_ENUM_OP_CONV("__rand__", a & b);
2163
+ PYBIND11_ENUM_OP_CONV("__or__", a | b);
2164
+ PYBIND11_ENUM_OP_CONV("__ror__", a | b);
2165
+ PYBIND11_ENUM_OP_CONV("__xor__", a ^ b);
2166
+ PYBIND11_ENUM_OP_CONV("__rxor__", a ^ b);
2167
+ m_base.attr("__invert__")
2168
+ = cpp_function([](const object &arg) { return ~(int_(arg)); },
2169
+ name("__invert__"),
2170
+ is_method(m_base));
2171
+ }
2172
+ } else {
2173
+ PYBIND11_ENUM_OP_STRICT("__eq__", int_(a).equal(int_(b)), return false);
2174
+ PYBIND11_ENUM_OP_STRICT("__ne__", !int_(a).equal(int_(b)), return true);
2175
+
2176
+ if (is_arithmetic) {
2177
+ #define PYBIND11_THROW throw type_error("Expected an enumeration of matching type!");
2178
+ PYBIND11_ENUM_OP_STRICT("__lt__", int_(a) < int_(b), PYBIND11_THROW);
2179
+ PYBIND11_ENUM_OP_STRICT("__gt__", int_(a) > int_(b), PYBIND11_THROW);
2180
+ PYBIND11_ENUM_OP_STRICT("__le__", int_(a) <= int_(b), PYBIND11_THROW);
2181
+ PYBIND11_ENUM_OP_STRICT("__ge__", int_(a) >= int_(b), PYBIND11_THROW);
2182
+ #undef PYBIND11_THROW
2183
+ }
2184
+ }
2185
+
2186
+ #undef PYBIND11_ENUM_OP_CONV_LHS
2187
+ #undef PYBIND11_ENUM_OP_CONV
2188
+ #undef PYBIND11_ENUM_OP_STRICT
2189
+
2190
+ m_base.attr("__getstate__") = cpp_function(
2191
+ [](const object &arg) { return int_(arg); }, name("__getstate__"), is_method(m_base));
2192
+
2193
+ m_base.attr("__hash__") = cpp_function(
2194
+ [](const object &arg) { return int_(arg); }, name("__hash__"), is_method(m_base));
2195
+ }
2196
+
2197
+ PYBIND11_NOINLINE void value(char const *name_, object value, const char *doc = nullptr) {
2198
+ dict entries = m_base.attr("__entries");
2199
+ str name(name_);
2200
+ if (entries.contains(name)) {
2201
+ std::string type_name = (std::string) str(m_base.attr("__name__"));
2202
+ throw value_error(std::move(type_name) + ": element \"" + std::string(name_)
2203
+ + "\" already exists!");
2204
+ }
2205
+
2206
+ entries[name] = pybind11::make_tuple(value, doc);
2207
+ m_base.attr(std::move(name)) = std::move(value);
2208
+ }
2209
+
2210
+ PYBIND11_NOINLINE void export_values() {
2211
+ dict entries = m_base.attr("__entries");
2212
+ for (auto kv : entries) {
2213
+ m_parent.attr(kv.first) = kv.second[int_(0)];
2214
+ }
2215
+ }
2216
+
2217
+ handle m_base;
2218
+ handle m_parent;
2219
+ };
2220
+
2221
+ template <bool is_signed, size_t length>
2222
+ struct equivalent_integer {};
2223
+ template <>
2224
+ struct equivalent_integer<true, 1> {
2225
+ using type = int8_t;
2226
+ };
2227
+ template <>
2228
+ struct equivalent_integer<false, 1> {
2229
+ using type = uint8_t;
2230
+ };
2231
+ template <>
2232
+ struct equivalent_integer<true, 2> {
2233
+ using type = int16_t;
2234
+ };
2235
+ template <>
2236
+ struct equivalent_integer<false, 2> {
2237
+ using type = uint16_t;
2238
+ };
2239
+ template <>
2240
+ struct equivalent_integer<true, 4> {
2241
+ using type = int32_t;
2242
+ };
2243
+ template <>
2244
+ struct equivalent_integer<false, 4> {
2245
+ using type = uint32_t;
2246
+ };
2247
+ template <>
2248
+ struct equivalent_integer<true, 8> {
2249
+ using type = int64_t;
2250
+ };
2251
+ template <>
2252
+ struct equivalent_integer<false, 8> {
2253
+ using type = uint64_t;
2254
+ };
2255
+
2256
+ template <typename IntLike>
2257
+ using equivalent_integer_t =
2258
+ typename equivalent_integer<std::is_signed<IntLike>::value, sizeof(IntLike)>::type;
2259
+
2260
+ PYBIND11_NAMESPACE_END(detail)
2261
+
2262
+ /// Binds C++ enumerations and enumeration classes to Python
2263
+ template <typename Type>
2264
+ class enum_ : public class_<Type> {
2265
+ public:
2266
+ using Base = class_<Type>;
2267
+ using Base::attr;
2268
+ using Base::def;
2269
+ using Base::def_property_readonly;
2270
+ using Base::def_property_readonly_static;
2271
+ using Underlying = typename std::underlying_type<Type>::type;
2272
+ // Scalar is the integer representation of underlying type
2273
+ using Scalar = detail::conditional_t<detail::any_of<detail::is_std_char_type<Underlying>,
2274
+ std::is_same<Underlying, bool>>::value,
2275
+ detail::equivalent_integer_t<Underlying>,
2276
+ Underlying>;
2277
+
2278
+ template <typename... Extra>
2279
+ enum_(const handle &scope, const char *name, const Extra &...extra)
2280
+ : class_<Type>(scope, name, extra...), m_base(*this, scope) {
2281
+ constexpr bool is_arithmetic = detail::any_of<std::is_same<arithmetic, Extra>...>::value;
2282
+ constexpr bool is_convertible = std::is_convertible<Type, Underlying>::value;
2283
+ m_base.init(is_arithmetic, is_convertible);
2284
+
2285
+ def(init([](Scalar i) { return static_cast<Type>(i); }), arg("value"));
2286
+ def_property_readonly("value", [](Type value) { return (Scalar) value; });
2287
+ def("__int__", [](Type value) { return (Scalar) value; });
2288
+ def("__index__", [](Type value) { return (Scalar) value; });
2289
+ attr("__setstate__") = cpp_function(
2290
+ [](detail::value_and_holder &v_h, Scalar arg) {
2291
+ detail::initimpl::setstate<Base>(
2292
+ v_h, static_cast<Type>(arg), Py_TYPE(v_h.inst) != v_h.type->type);
2293
+ },
2294
+ detail::is_new_style_constructor(),
2295
+ pybind11::name("__setstate__"),
2296
+ is_method(*this),
2297
+ arg("state"));
2298
+ }
2299
+
2300
+ /// Export enumeration entries into the parent scope
2301
+ enum_ &export_values() {
2302
+ m_base.export_values();
2303
+ return *this;
2304
+ }
2305
+
2306
+ /// Add an enumeration entry
2307
+ enum_ &value(char const *name, Type value, const char *doc = nullptr) {
2308
+ m_base.value(name, pybind11::cast(value, return_value_policy::copy), doc);
2309
+ return *this;
2310
+ }
2311
+
2312
+ private:
2313
+ detail::enum_base m_base;
2314
+ };
2315
+
2316
+ PYBIND11_NAMESPACE_BEGIN(detail)
2317
+
2318
+ PYBIND11_NOINLINE void keep_alive_impl(handle nurse, handle patient) {
2319
+ if (!nurse || !patient) {
2320
+ pybind11_fail("Could not activate keep_alive!");
2321
+ }
2322
+
2323
+ if (patient.is_none() || nurse.is_none()) {
2324
+ return; /* Nothing to keep alive or nothing to be kept alive by */
2325
+ }
2326
+
2327
+ auto tinfo = all_type_info(Py_TYPE(nurse.ptr()));
2328
+ if (!tinfo.empty()) {
2329
+ /* It's a pybind-registered type, so we can store the patient in the
2330
+ * internal list. */
2331
+ add_patient(nurse.ptr(), patient.ptr());
2332
+ } else {
2333
+ /* Fall back to clever approach based on weak references taken from
2334
+ * Boost.Python. This is not used for pybind-registered types because
2335
+ * the objects can be destroyed out-of-order in a GC pass. */
2336
+ cpp_function disable_lifesupport([patient](handle weakref) {
2337
+ patient.dec_ref();
2338
+ weakref.dec_ref();
2339
+ });
2340
+
2341
+ weakref wr(nurse, disable_lifesupport);
2342
+
2343
+ patient.inc_ref(); /* reference patient and leak the weak reference */
2344
+ (void) wr.release();
2345
+ }
2346
+ }
2347
+
2348
+ PYBIND11_NOINLINE void
2349
+ keep_alive_impl(size_t Nurse, size_t Patient, function_call &call, handle ret) {
2350
+ auto get_arg = [&](size_t n) {
2351
+ if (n == 0) {
2352
+ return ret;
2353
+ }
2354
+ if (n == 1 && call.init_self) {
2355
+ return call.init_self;
2356
+ }
2357
+ if (n <= call.args.size()) {
2358
+ return call.args[n - 1];
2359
+ }
2360
+ return handle();
2361
+ };
2362
+
2363
+ keep_alive_impl(get_arg(Nurse), get_arg(Patient));
2364
+ }
2365
+
2366
+ inline std::pair<decltype(internals::registered_types_py)::iterator, bool>
2367
+ all_type_info_get_cache(PyTypeObject *type) {
2368
+ auto res = with_internals([type](internals &internals) {
2369
+ return internals
2370
+ .registered_types_py
2371
+ #ifdef __cpp_lib_unordered_map_try_emplace
2372
+ .try_emplace(type);
2373
+ #else
2374
+ .emplace(type, std::vector<detail::type_info *>());
2375
+ #endif
2376
+ });
2377
+ if (res.second) {
2378
+ // New cache entry created; set up a weak reference to automatically remove it if the type
2379
+ // gets destroyed:
2380
+ weakref((PyObject *) type, cpp_function([type](handle wr) {
2381
+ with_internals([type](internals &internals) {
2382
+ internals.registered_types_py.erase(type);
2383
+
2384
+ // TODO consolidate the erasure code in pybind11_meta_dealloc() in class.h
2385
+ auto &cache = internals.inactive_override_cache;
2386
+ for (auto it = cache.begin(), last = cache.end(); it != last;) {
2387
+ if (it->first == reinterpret_cast<PyObject *>(type)) {
2388
+ it = cache.erase(it);
2389
+ } else {
2390
+ ++it;
2391
+ }
2392
+ }
2393
+ });
2394
+
2395
+ wr.dec_ref();
2396
+ }))
2397
+ .release();
2398
+ }
2399
+
2400
+ return res;
2401
+ }
2402
+
2403
+ /* There are a large number of apparently unused template arguments because
2404
+ * each combination requires a separate py::class_ registration.
2405
+ */
2406
+ template <typename Access,
2407
+ return_value_policy Policy,
2408
+ typename Iterator,
2409
+ typename Sentinel,
2410
+ typename ValueType,
2411
+ typename... Extra>
2412
+ struct iterator_state {
2413
+ Iterator it;
2414
+ Sentinel end;
2415
+ bool first_or_done;
2416
+ };
2417
+
2418
+ // Note: these helpers take the iterator by non-const reference because some
2419
+ // iterators in the wild can't be dereferenced when const. The & after Iterator
2420
+ // is required for MSVC < 16.9. SFINAE cannot be reused for result_type due to
2421
+ // bugs in ICC, NVCC, and PGI compilers. See PR #3293.
2422
+ template <typename Iterator, typename SFINAE = decltype(*std::declval<Iterator &>())>
2423
+ struct iterator_access {
2424
+ using result_type = decltype(*std::declval<Iterator &>());
2425
+ // NOLINTNEXTLINE(readability-const-return-type) // PR #3263
2426
+ result_type operator()(Iterator &it) const { return *it; }
2427
+ };
2428
+
2429
+ template <typename Iterator, typename SFINAE = decltype((*std::declval<Iterator &>()).first)>
2430
+ class iterator_key_access {
2431
+ private:
2432
+ using pair_type = decltype(*std::declval<Iterator &>());
2433
+
2434
+ public:
2435
+ /* If either the pair itself or the element of the pair is a reference, we
2436
+ * want to return a reference, otherwise a value. When the decltype
2437
+ * expression is parenthesized it is based on the value category of the
2438
+ * expression; otherwise it is the declared type of the pair member.
2439
+ * The use of declval<pair_type> in the second branch rather than directly
2440
+ * using *std::declval<Iterator &>() is a workaround for nvcc
2441
+ * (it's not used in the first branch because going via decltype and back
2442
+ * through declval does not perfectly preserve references).
2443
+ */
2444
+ using result_type
2445
+ = conditional_t<std::is_reference<decltype(*std::declval<Iterator &>())>::value,
2446
+ decltype(((*std::declval<Iterator &>()).first)),
2447
+ decltype(std::declval<pair_type>().first)>;
2448
+ result_type operator()(Iterator &it) const { return (*it).first; }
2449
+ };
2450
+
2451
+ template <typename Iterator, typename SFINAE = decltype((*std::declval<Iterator &>()).second)>
2452
+ class iterator_value_access {
2453
+ private:
2454
+ using pair_type = decltype(*std::declval<Iterator &>());
2455
+
2456
+ public:
2457
+ using result_type
2458
+ = conditional_t<std::is_reference<decltype(*std::declval<Iterator &>())>::value,
2459
+ decltype(((*std::declval<Iterator &>()).second)),
2460
+ decltype(std::declval<pair_type>().second)>;
2461
+ result_type operator()(Iterator &it) const { return (*it).second; }
2462
+ };
2463
+
2464
+ template <typename Access,
2465
+ return_value_policy Policy,
2466
+ typename Iterator,
2467
+ typename Sentinel,
2468
+ typename ValueType,
2469
+ typename... Extra>
2470
+ iterator make_iterator_impl(Iterator first, Sentinel last, Extra &&...extra) {
2471
+ using state = detail::iterator_state<Access, Policy, Iterator, Sentinel, ValueType, Extra...>;
2472
+ // TODO: state captures only the types of Extra, not the values
2473
+
2474
+ if (!detail::get_type_info(typeid(state), false)) {
2475
+ class_<state>(handle(), "iterator", pybind11::module_local())
2476
+ .def("__iter__", [](state &s) -> state & { return s; })
2477
+ .def(
2478
+ "__next__",
2479
+ [](state &s) -> ValueType {
2480
+ if (!s.first_or_done) {
2481
+ ++s.it;
2482
+ } else {
2483
+ s.first_or_done = false;
2484
+ }
2485
+ if (s.it == s.end) {
2486
+ s.first_or_done = true;
2487
+ throw stop_iteration();
2488
+ }
2489
+ return Access()(s.it);
2490
+ // NOLINTNEXTLINE(readability-const-return-type) // PR #3263
2491
+ },
2492
+ std::forward<Extra>(extra)...,
2493
+ Policy);
2494
+ }
2495
+
2496
+ return cast(state{std::forward<Iterator>(first), std::forward<Sentinel>(last), true});
2497
+ }
2498
+
2499
+ PYBIND11_NAMESPACE_END(detail)
2500
+
2501
+ /// Makes a python iterator from a first and past-the-end C++ InputIterator.
2502
+ template <return_value_policy Policy = return_value_policy::reference_internal,
2503
+ typename Iterator,
2504
+ typename Sentinel,
2505
+ typename ValueType = typename detail::iterator_access<Iterator>::result_type,
2506
+ typename... Extra>
2507
+ typing::Iterator<ValueType> make_iterator(Iterator first, Sentinel last, Extra &&...extra) {
2508
+ return detail::make_iterator_impl<detail::iterator_access<Iterator>,
2509
+ Policy,
2510
+ Iterator,
2511
+ Sentinel,
2512
+ ValueType,
2513
+ Extra...>(std::forward<Iterator>(first),
2514
+ std::forward<Sentinel>(last),
2515
+ std::forward<Extra>(extra)...);
2516
+ }
2517
+
2518
+ /// Makes a python iterator over the keys (`.first`) of a iterator over pairs from a
2519
+ /// first and past-the-end InputIterator.
2520
+ template <return_value_policy Policy = return_value_policy::reference_internal,
2521
+ typename Iterator,
2522
+ typename Sentinel,
2523
+ typename KeyType = typename detail::iterator_key_access<Iterator>::result_type,
2524
+ typename... Extra>
2525
+ typing::Iterator<KeyType> make_key_iterator(Iterator first, Sentinel last, Extra &&...extra) {
2526
+ return detail::make_iterator_impl<detail::iterator_key_access<Iterator>,
2527
+ Policy,
2528
+ Iterator,
2529
+ Sentinel,
2530
+ KeyType,
2531
+ Extra...>(std::forward<Iterator>(first),
2532
+ std::forward<Sentinel>(last),
2533
+ std::forward<Extra>(extra)...);
2534
+ }
2535
+
2536
+ /// Makes a python iterator over the values (`.second`) of a iterator over pairs from a
2537
+ /// first and past-the-end InputIterator.
2538
+ template <return_value_policy Policy = return_value_policy::reference_internal,
2539
+ typename Iterator,
2540
+ typename Sentinel,
2541
+ typename ValueType = typename detail::iterator_value_access<Iterator>::result_type,
2542
+ typename... Extra>
2543
+ typing::Iterator<ValueType> make_value_iterator(Iterator first, Sentinel last, Extra &&...extra) {
2544
+ return detail::make_iterator_impl<detail::iterator_value_access<Iterator>,
2545
+ Policy,
2546
+ Iterator,
2547
+ Sentinel,
2548
+ ValueType,
2549
+ Extra...>(std::forward<Iterator>(first),
2550
+ std::forward<Sentinel>(last),
2551
+ std::forward<Extra>(extra)...);
2552
+ }
2553
+
2554
+ /// Makes an iterator over values of an stl container or other container supporting
2555
+ /// `std::begin()`/`std::end()`
2556
+ template <return_value_policy Policy = return_value_policy::reference_internal,
2557
+ typename Type,
2558
+ typename ValueType = typename detail::iterator_access<
2559
+ decltype(std::begin(std::declval<Type &>()))>::result_type,
2560
+ typename... Extra>
2561
+ typing::Iterator<ValueType> make_iterator(Type &value, Extra &&...extra) {
2562
+ return make_iterator<Policy>(
2563
+ std::begin(value), std::end(value), std::forward<Extra>(extra)...);
2564
+ }
2565
+
2566
+ /// Makes an iterator over the keys (`.first`) of a stl map-like container supporting
2567
+ /// `std::begin()`/`std::end()`
2568
+ template <return_value_policy Policy = return_value_policy::reference_internal,
2569
+ typename Type,
2570
+ typename KeyType = typename detail::iterator_key_access<
2571
+ decltype(std::begin(std::declval<Type &>()))>::result_type,
2572
+ typename... Extra>
2573
+ typing::Iterator<KeyType> make_key_iterator(Type &value, Extra &&...extra) {
2574
+ return make_key_iterator<Policy>(
2575
+ std::begin(value), std::end(value), std::forward<Extra>(extra)...);
2576
+ }
2577
+
2578
+ /// Makes an iterator over the values (`.second`) of a stl map-like container supporting
2579
+ /// `std::begin()`/`std::end()`
2580
+ template <return_value_policy Policy = return_value_policy::reference_internal,
2581
+ typename Type,
2582
+ typename ValueType = typename detail::iterator_value_access<
2583
+ decltype(std::begin(std::declval<Type &>()))>::result_type,
2584
+ typename... Extra>
2585
+ typing::Iterator<ValueType> make_value_iterator(Type &value, Extra &&...extra) {
2586
+ return make_value_iterator<Policy>(
2587
+ std::begin(value), std::end(value), std::forward<Extra>(extra)...);
2588
+ }
2589
+
2590
+ template <typename InputType, typename OutputType>
2591
+ void implicitly_convertible() {
2592
+ struct set_flag {
2593
+ bool &flag;
2594
+ explicit set_flag(bool &flag_) : flag(flag_) { flag_ = true; }
2595
+ ~set_flag() { flag = false; }
2596
+ };
2597
+ auto implicit_caster = [](PyObject *obj, PyTypeObject *type) -> PyObject * {
2598
+ #ifdef Py_GIL_DISABLED
2599
+ thread_local bool currently_used = false;
2600
+ #else
2601
+ static bool currently_used = false;
2602
+ #endif
2603
+ if (currently_used) { // implicit conversions are non-reentrant
2604
+ return nullptr;
2605
+ }
2606
+ set_flag flag_helper(currently_used);
2607
+ if (!detail::make_caster<InputType>().load(obj, false)) {
2608
+ return nullptr;
2609
+ }
2610
+ tuple args(1);
2611
+ args[0] = obj;
2612
+ PyObject *result = PyObject_Call((PyObject *) type, args.ptr(), nullptr);
2613
+ if (result == nullptr) {
2614
+ PyErr_Clear();
2615
+ }
2616
+ return result;
2617
+ };
2618
+
2619
+ if (auto *tinfo = detail::get_type_info(typeid(OutputType))) {
2620
+ tinfo->implicit_conversions.emplace_back(std::move(implicit_caster));
2621
+ } else {
2622
+ pybind11_fail("implicitly_convertible: Unable to find type " + type_id<OutputType>());
2623
+ }
2624
+ }
2625
+
2626
+ inline void register_exception_translator(ExceptionTranslator &&translator) {
2627
+ detail::with_internals([&](detail::internals &internals) {
2628
+ internals.registered_exception_translators.push_front(
2629
+ std::forward<ExceptionTranslator>(translator));
2630
+ });
2631
+ }
2632
+
2633
+ /**
2634
+ * Add a new module-local exception translator. Locally registered functions
2635
+ * will be tried before any globally registered exception translators, which
2636
+ * will only be invoked if the module-local handlers do not deal with
2637
+ * the exception.
2638
+ */
2639
+ inline void register_local_exception_translator(ExceptionTranslator &&translator) {
2640
+ detail::with_internals([&](detail::internals &internals) {
2641
+ (void) internals;
2642
+ detail::get_local_internals().registered_exception_translators.push_front(
2643
+ std::forward<ExceptionTranslator>(translator));
2644
+ });
2645
+ }
2646
+
2647
+ /**
2648
+ * Wrapper to generate a new Python exception type.
2649
+ *
2650
+ * This should only be used with py::set_error() for now.
2651
+ * It is not (yet) possible to use as a py::base.
2652
+ * Template type argument is reserved for future use.
2653
+ */
2654
+ template <typename type>
2655
+ class exception : public object {
2656
+ public:
2657
+ exception() = default;
2658
+ exception(handle scope, const char *name, handle base = PyExc_Exception) {
2659
+ std::string full_name
2660
+ = scope.attr("__name__").cast<std::string>() + std::string(".") + name;
2661
+ m_ptr = PyErr_NewException(const_cast<char *>(full_name.c_str()), base.ptr(), nullptr);
2662
+ if (hasattr(scope, "__dict__") && scope.attr("__dict__").contains(name)) {
2663
+ pybind11_fail("Error during initialization: multiple incompatible "
2664
+ "definitions with name \""
2665
+ + std::string(name) + "\"");
2666
+ }
2667
+ scope.attr(name) = *this;
2668
+ }
2669
+
2670
+ // Sets the current python exception to this exception object with the given message
2671
+ PYBIND11_DEPRECATED("Please use py::set_error() instead "
2672
+ "(https://github.com/pybind/pybind11/pull/4772)")
2673
+ void operator()(const char *message) const { set_error(*this, message); }
2674
+ };
2675
+
2676
+ PYBIND11_NAMESPACE_BEGIN(detail)
2677
+
2678
+ template <>
2679
+ struct handle_type_name<exception<void>> {
2680
+ static constexpr auto name = const_name("Exception");
2681
+ };
2682
+
2683
+ // Helper function for register_exception and register_local_exception
2684
+ template <typename CppException>
2685
+ exception<CppException> &
2686
+ register_exception_impl(handle scope, const char *name, handle base, bool isLocal) {
2687
+ PYBIND11_CONSTINIT static gil_safe_call_once_and_store<exception<CppException>> exc_storage;
2688
+ exc_storage.call_once_and_store_result(
2689
+ [&]() { return exception<CppException>(scope, name, base); });
2690
+
2691
+ auto register_func
2692
+ = isLocal ? &register_local_exception_translator : &register_exception_translator;
2693
+
2694
+ register_func([](std::exception_ptr p) {
2695
+ if (!p) {
2696
+ return;
2697
+ }
2698
+ try {
2699
+ std::rethrow_exception(p);
2700
+ } catch (const CppException &e) {
2701
+ set_error(exc_storage.get_stored(), e.what());
2702
+ }
2703
+ });
2704
+ return exc_storage.get_stored();
2705
+ }
2706
+
2707
+ PYBIND11_NAMESPACE_END(detail)
2708
+
2709
+ /**
2710
+ * Registers a Python exception in `m` of the given `name` and installs a translator to
2711
+ * translate the C++ exception to the created Python exception using the what() method.
2712
+ * This is intended for simple exception translations; for more complex translation, register the
2713
+ * exception object and translator directly.
2714
+ */
2715
+ template <typename CppException>
2716
+ exception<CppException> &
2717
+ register_exception(handle scope, const char *name, handle base = PyExc_Exception) {
2718
+ return detail::register_exception_impl<CppException>(scope, name, base, false /* isLocal */);
2719
+ }
2720
+
2721
+ /**
2722
+ * Registers a Python exception in `m` of the given `name` and installs a translator to
2723
+ * translate the C++ exception to the created Python exception using the what() method.
2724
+ * This translator will only be used for exceptions that are thrown in this module and will be
2725
+ * tried before global exception translators, including those registered with register_exception.
2726
+ * This is intended for simple exception translations; for more complex translation, register the
2727
+ * exception object and translator directly.
2728
+ */
2729
+ template <typename CppException>
2730
+ exception<CppException> &
2731
+ register_local_exception(handle scope, const char *name, handle base = PyExc_Exception) {
2732
+ return detail::register_exception_impl<CppException>(scope, name, base, true /* isLocal */);
2733
+ }
2734
+
2735
+ PYBIND11_NAMESPACE_BEGIN(detail)
2736
+ PYBIND11_NOINLINE void print(const tuple &args, const dict &kwargs) {
2737
+ auto strings = tuple(args.size());
2738
+ for (size_t i = 0; i < args.size(); ++i) {
2739
+ strings[i] = str(args[i]);
2740
+ }
2741
+ auto sep = kwargs.contains("sep") ? kwargs["sep"] : str(" ");
2742
+ auto line = sep.attr("join")(std::move(strings));
2743
+
2744
+ object file;
2745
+ if (kwargs.contains("file")) {
2746
+ file = kwargs["file"].cast<object>();
2747
+ } else {
2748
+ try {
2749
+ file = module_::import("sys").attr("stdout");
2750
+ } catch (const error_already_set &) {
2751
+ /* If print() is called from code that is executed as
2752
+ part of garbage collection during interpreter shutdown,
2753
+ importing 'sys' can fail. Give up rather than crashing the
2754
+ interpreter in this case. */
2755
+ return;
2756
+ }
2757
+ }
2758
+
2759
+ auto write = file.attr("write");
2760
+ write(std::move(line));
2761
+ write(kwargs.contains("end") ? kwargs["end"] : str("\n"));
2762
+
2763
+ if (kwargs.contains("flush") && kwargs["flush"].cast<bool>()) {
2764
+ file.attr("flush")();
2765
+ }
2766
+ }
2767
+ PYBIND11_NAMESPACE_END(detail)
2768
+
2769
+ template <return_value_policy policy = return_value_policy::automatic_reference, typename... Args>
2770
+ void print(Args &&...args) {
2771
+ auto c = detail::collect_arguments<policy>(std::forward<Args>(args)...);
2772
+ detail::print(c.args(), c.kwargs());
2773
+ }
2774
+
2775
+ inline void
2776
+ error_already_set::m_fetched_error_deleter(detail::error_fetch_and_normalize *raw_ptr) {
2777
+ gil_scoped_acquire gil;
2778
+ error_scope scope;
2779
+ delete raw_ptr;
2780
+ }
2781
+
2782
+ inline const char *error_already_set::what() const noexcept {
2783
+ gil_scoped_acquire gil;
2784
+ error_scope scope;
2785
+ return m_fetched_error->error_string().c_str();
2786
+ }
2787
+
2788
+ PYBIND11_NAMESPACE_BEGIN(detail)
2789
+
2790
+ inline function
2791
+ get_type_override(const void *this_ptr, const type_info *this_type, const char *name) {
2792
+ handle self = get_object_handle(this_ptr, this_type);
2793
+ if (!self) {
2794
+ return function();
2795
+ }
2796
+ handle type = type::handle_of(self);
2797
+ auto key = std::make_pair(type.ptr(), name);
2798
+
2799
+ /* Cache functions that aren't overridden in Python to avoid
2800
+ many costly Python dictionary lookups below */
2801
+ bool not_overridden = with_internals([&key](internals &internals) {
2802
+ auto &cache = internals.inactive_override_cache;
2803
+ return cache.find(key) != cache.end();
2804
+ });
2805
+ if (not_overridden) {
2806
+ return function();
2807
+ }
2808
+
2809
+ function override = getattr(self, name, function());
2810
+ if (override.is_cpp_function()) {
2811
+ with_internals([&](internals &internals) {
2812
+ internals.inactive_override_cache.insert(std::move(key));
2813
+ });
2814
+ return function();
2815
+ }
2816
+
2817
+ /* Don't call dispatch code if invoked from overridden function.
2818
+ Unfortunately this doesn't work on PyPy. */
2819
+ #if !defined(PYPY_VERSION)
2820
+ # if PY_VERSION_HEX >= 0x03090000
2821
+ PyFrameObject *frame = PyThreadState_GetFrame(PyThreadState_Get());
2822
+ if (frame != nullptr) {
2823
+ PyCodeObject *f_code = PyFrame_GetCode(frame);
2824
+ // f_code is guaranteed to not be NULL
2825
+ if ((std::string) str(f_code->co_name) == name && f_code->co_argcount > 0) {
2826
+ # if PY_VERSION_HEX >= 0x030d0000
2827
+ PyObject *locals = PyEval_GetFrameLocals();
2828
+ # else
2829
+ PyObject *locals = PyEval_GetLocals();
2830
+ Py_XINCREF(locals);
2831
+ # endif
2832
+ if (locals != nullptr) {
2833
+ # if PY_VERSION_HEX >= 0x030b0000
2834
+ PyObject *co_varnames = PyCode_GetVarnames(f_code);
2835
+ # else
2836
+ PyObject *co_varnames = PyObject_GetAttrString((PyObject *) f_code, "co_varnames");
2837
+ # endif
2838
+ PyObject *self_arg = PyTuple_GET_ITEM(co_varnames, 0);
2839
+ Py_DECREF(co_varnames);
2840
+ PyObject *self_caller = dict_getitem(locals, self_arg);
2841
+ Py_DECREF(locals);
2842
+ if (self_caller == self.ptr()) {
2843
+ Py_DECREF(f_code);
2844
+ Py_DECREF(frame);
2845
+ return function();
2846
+ }
2847
+ }
2848
+ }
2849
+ Py_DECREF(f_code);
2850
+ Py_DECREF(frame);
2851
+ }
2852
+ # else
2853
+ PyFrameObject *frame = PyThreadState_Get()->frame;
2854
+ if (frame != nullptr && (std::string) str(frame->f_code->co_name) == name
2855
+ && frame->f_code->co_argcount > 0) {
2856
+ PyFrame_FastToLocals(frame);
2857
+ PyObject *self_caller
2858
+ = dict_getitem(frame->f_locals, PyTuple_GET_ITEM(frame->f_code->co_varnames, 0));
2859
+ if (self_caller == self.ptr()) {
2860
+ return function();
2861
+ }
2862
+ }
2863
+ # endif
2864
+
2865
+ #else
2866
+ /* PyPy currently doesn't provide a detailed cpyext emulation of
2867
+ frame objects, so we have to emulate this using Python. This
2868
+ is going to be slow..*/
2869
+ dict d;
2870
+ d["self"] = self;
2871
+ d["name"] = pybind11::str(name);
2872
+ PyObject *result
2873
+ = PyRun_String("import inspect\n"
2874
+ "frame = inspect.currentframe()\n"
2875
+ "if frame is not None:\n"
2876
+ " frame = frame.f_back\n"
2877
+ " if frame is not None and str(frame.f_code.co_name) == name and "
2878
+ "frame.f_code.co_argcount > 0:\n"
2879
+ " self_caller = frame.f_locals[frame.f_code.co_varnames[0]]\n"
2880
+ " if self_caller == self:\n"
2881
+ " self = None\n",
2882
+ Py_file_input,
2883
+ d.ptr(),
2884
+ d.ptr());
2885
+ if (result == nullptr)
2886
+ throw error_already_set();
2887
+ Py_DECREF(result);
2888
+ if (d["self"].is_none())
2889
+ return function();
2890
+ #endif
2891
+
2892
+ return override;
2893
+ }
2894
+ PYBIND11_NAMESPACE_END(detail)
2895
+
2896
+ /** \rst
2897
+ Try to retrieve a python method by the provided name from the instance pointed to by the
2898
+ this_ptr.
2899
+
2900
+ :this_ptr: The pointer to the object the overridden method should be retrieved for. This should
2901
+ be the first non-trampoline class encountered in the inheritance chain.
2902
+ :name: The name of the overridden Python method to retrieve.
2903
+ :return: The Python method by this name from the object or an empty function wrapper.
2904
+ \endrst */
2905
+ template <class T>
2906
+ function get_override(const T *this_ptr, const char *name) {
2907
+ auto *tinfo = detail::get_type_info(typeid(T));
2908
+ return tinfo ? detail::get_type_override(this_ptr, tinfo, name) : function();
2909
+ }
2910
+
2911
+ #define PYBIND11_OVERRIDE_IMPL(ret_type, cname, name, ...) \
2912
+ do { \
2913
+ pybind11::gil_scoped_acquire gil; \
2914
+ pybind11::function override \
2915
+ = pybind11::get_override(static_cast<const cname *>(this), name); \
2916
+ if (override) { \
2917
+ auto o = override(__VA_ARGS__); \
2918
+ PYBIND11_WARNING_PUSH \
2919
+ PYBIND11_WARNING_DISABLE_MSVC(4127) \
2920
+ if (pybind11::detail::cast_is_temporary_value_reference<ret_type>::value \
2921
+ && !pybind11::detail::is_same_ignoring_cvref<ret_type, PyObject *>::value) { \
2922
+ static pybind11::detail::override_caster_t<ret_type> caster; \
2923
+ return pybind11::detail::cast_ref<ret_type>(std::move(o), caster); \
2924
+ } \
2925
+ PYBIND11_WARNING_POP \
2926
+ return pybind11::detail::cast_safe<ret_type>(std::move(o)); \
2927
+ } \
2928
+ } while (false)
2929
+
2930
+ /** \rst
2931
+ Macro to populate the virtual method in the trampoline class. This macro tries to look up a
2932
+ method named 'fn' from the Python side, deals with the :ref:`gil` and necessary argument
2933
+ conversions to call this method and return the appropriate type.
2934
+ See :ref:`overriding_virtuals` for more information. This macro should be used when the method
2935
+ name in C is not the same as the method name in Python. For example with `__str__`.
2936
+
2937
+ .. code-block:: cpp
2938
+
2939
+ std::string toString() override {
2940
+ PYBIND11_OVERRIDE_NAME(
2941
+ std::string, // Return type (ret_type)
2942
+ Animal, // Parent class (cname)
2943
+ "__str__", // Name of method in Python (name)
2944
+ toString, // Name of function in C++ (fn)
2945
+ );
2946
+ }
2947
+ \endrst */
2948
+ #define PYBIND11_OVERRIDE_NAME(ret_type, cname, name, fn, ...) \
2949
+ do { \
2950
+ PYBIND11_OVERRIDE_IMPL(PYBIND11_TYPE(ret_type), PYBIND11_TYPE(cname), name, __VA_ARGS__); \
2951
+ return cname::fn(__VA_ARGS__); \
2952
+ } while (false)
2953
+
2954
+ /** \rst
2955
+ Macro for pure virtual functions, this function is identical to
2956
+ :c:macro:`PYBIND11_OVERRIDE_NAME`, except that it throws if no override can be found.
2957
+ \endrst */
2958
+ #define PYBIND11_OVERRIDE_PURE_NAME(ret_type, cname, name, fn, ...) \
2959
+ do { \
2960
+ PYBIND11_OVERRIDE_IMPL(PYBIND11_TYPE(ret_type), PYBIND11_TYPE(cname), name, __VA_ARGS__); \
2961
+ pybind11::pybind11_fail( \
2962
+ "Tried to call pure virtual function \"" PYBIND11_STRINGIFY(cname) "::" name "\""); \
2963
+ } while (false)
2964
+
2965
+ /** \rst
2966
+ Macro to populate the virtual method in the trampoline class. This macro tries to look up the
2967
+ method from the Python side, deals with the :ref:`gil` and necessary argument conversions to
2968
+ call this method and return the appropriate type. This macro should be used if the method name
2969
+ in C and in Python are identical.
2970
+ See :ref:`overriding_virtuals` for more information.
2971
+
2972
+ .. code-block:: cpp
2973
+
2974
+ class PyAnimal : public Animal {
2975
+ public:
2976
+ // Inherit the constructors
2977
+ using Animal::Animal;
2978
+
2979
+ // Trampoline (need one for each virtual function)
2980
+ std::string go(int n_times) override {
2981
+ PYBIND11_OVERRIDE_PURE(
2982
+ std::string, // Return type (ret_type)
2983
+ Animal, // Parent class (cname)
2984
+ go, // Name of function in C++ (must match Python name) (fn)
2985
+ n_times // Argument(s) (...)
2986
+ );
2987
+ }
2988
+ };
2989
+ \endrst */
2990
+ #define PYBIND11_OVERRIDE(ret_type, cname, fn, ...) \
2991
+ PYBIND11_OVERRIDE_NAME(PYBIND11_TYPE(ret_type), PYBIND11_TYPE(cname), #fn, fn, __VA_ARGS__)
2992
+
2993
+ /** \rst
2994
+ Macro for pure virtual functions, this function is identical to :c:macro:`PYBIND11_OVERRIDE`,
2995
+ except that it throws if no override can be found.
2996
+ \endrst */
2997
+ #define PYBIND11_OVERRIDE_PURE(ret_type, cname, fn, ...) \
2998
+ PYBIND11_OVERRIDE_PURE_NAME( \
2999
+ PYBIND11_TYPE(ret_type), PYBIND11_TYPE(cname), #fn, fn, __VA_ARGS__)
3000
+
3001
+ // Deprecated versions
3002
+
3003
+ PYBIND11_DEPRECATED("get_type_overload has been deprecated")
3004
+ inline function
3005
+ get_type_overload(const void *this_ptr, const detail::type_info *this_type, const char *name) {
3006
+ return detail::get_type_override(this_ptr, this_type, name);
3007
+ }
3008
+
3009
+ template <class T>
3010
+ inline function get_overload(const T *this_ptr, const char *name) {
3011
+ return get_override(this_ptr, name);
3012
+ }
3013
+
3014
+ #define PYBIND11_OVERLOAD_INT(ret_type, cname, name, ...) \
3015
+ PYBIND11_OVERRIDE_IMPL(PYBIND11_TYPE(ret_type), PYBIND11_TYPE(cname), name, __VA_ARGS__)
3016
+ #define PYBIND11_OVERLOAD_NAME(ret_type, cname, name, fn, ...) \
3017
+ PYBIND11_OVERRIDE_NAME(PYBIND11_TYPE(ret_type), PYBIND11_TYPE(cname), name, fn, __VA_ARGS__)
3018
+ #define PYBIND11_OVERLOAD_PURE_NAME(ret_type, cname, name, fn, ...) \
3019
+ PYBIND11_OVERRIDE_PURE_NAME( \
3020
+ PYBIND11_TYPE(ret_type), PYBIND11_TYPE(cname), name, fn, __VA_ARGS__);
3021
+ #define PYBIND11_OVERLOAD(ret_type, cname, fn, ...) \
3022
+ PYBIND11_OVERRIDE(PYBIND11_TYPE(ret_type), PYBIND11_TYPE(cname), fn, __VA_ARGS__)
3023
+ #define PYBIND11_OVERLOAD_PURE(ret_type, cname, fn, ...) \
3024
+ PYBIND11_OVERRIDE_PURE(PYBIND11_TYPE(ret_type), PYBIND11_TYPE(cname), fn, __VA_ARGS__);
3025
+
3026
+ PYBIND11_NAMESPACE_END(PYBIND11_NAMESPACE)