MCPcopy Create free account
hub / github.com/Tencent/MMKV / encodeFloat

Function encodeFloat

OpenHarmony/MMKV/src/main/cpp/native_bridge.cpp:903–922  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

901}
902
903static napi_value encodeFloat(napi_env env, napi_callback_info info) {
904 size_t argc = 4;
905 napi_value args[4] = {nullptr};
906 NAPI_CALL(napi_get_cb_info(env, info, &argc, args, nullptr, nullptr));
907
908 auto handle = NValueToUInt64(env, args[0]);
909 auto key = NValueToString(env, args[1]);
910 MMKV *kv = reinterpret_cast<MMKV *>(handle);
911 if (kv && key.length() > 0) {
912 float value = NValueToDouble(env, args[2]);
913 if (IsNValueUndefined(env, args[3])) {
914 auto ret = kv->set(value, key);
915 return BoolToNValue(env, ret);
916 }
917 uint32_t expiration = NValueToUInt32(env, args[3]);
918 auto ret = kv->set(value, key, expiration);
919 return BoolToNValue(env, ret);
920 }
921 return BoolToNValue(env, false);
922}
923
924static napi_value decodeFloat(napi_env env, napi_callback_info info) {
925 size_t argc = 3;

Callers

nothing calls this directly

Calls 7

NValueToUInt64Function · 0.85
NValueToDoubleFunction · 0.85
NValueToUInt32Function · 0.85
NValueToStringFunction · 0.70
IsNValueUndefinedFunction · 0.70
BoolToNValueFunction · 0.70
setMethod · 0.45

Tested by

no test coverage detected