mirror of
https://github.com/facebook/react-native.git
synced 2026-11-18 20:19:07 +00:00
Apply clang-tidy setting: react/nativemodule (#52740)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/52740 Changelog: [Internal] Reviewed By: cipolleschi Differential Revision: D78634926 fbshipit-source-id: f2218a3ac9b60550e0b71b8533a1fd5062f1d610
This commit is contained in:
1 parent
5ef41068ed
commit
2d220624c7
20 files changed
+124
-94
No files matched your search
@@ -7,33 +7,38 @@
|
||||
|
||||
#include "BridgingTest.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
namespace facebook::react {
|
||||
|
||||
using namespace std::literals;
|
||||
|
||||
struct TestClass {
|
||||
TestClass(std::shared_ptr<CallInvoker> invoker) : invoker_(invoker) {}
|
||||
explicit TestClass(std::shared_ptr<CallInvoker> invoker)
|
||||
: invoker_(std::move(invoker)) {}
|
||||
|
||||
double add(jsi::Runtime&, int a, float b) {
|
||||
double add(jsi::Runtime& /*unused*/, int a, float b) {
|
||||
return a + b;
|
||||
}
|
||||
|
||||
jsi::Object getObject(jsi::Runtime&, jsi::Object obj) {
|
||||
jsi::Object getObject(jsi::Runtime& /*unused*/, jsi::Object obj) {
|
||||
return obj;
|
||||
}
|
||||
|
||||
AsyncPromise<std::string> getPromise(jsi::Runtime& rt, std::string result) {
|
||||
auto promise = AsyncPromise<std::string>(rt, invoker_);
|
||||
promise.resolve(result);
|
||||
promise.resolve(std::move(result));
|
||||
return promise;
|
||||
}
|
||||
|
||||
std::string
|
||||
callFunc(jsi::Runtime&, SyncCallback<std::string(int)> func, int num) {
|
||||
std::string callFunc(
|
||||
jsi::Runtime& /*unused*/,
|
||||
SyncCallback<std::string(int)> func,
|
||||
int num) {
|
||||
return func(num);
|
||||
}
|
||||
|
||||
void callAsync(jsi::Runtime&, AsyncCallback<> callback) {
|
||||
void callAsync(jsi::Runtime& /*unused*/, const AsyncCallback<>& callback) {
|
||||
callback();
|
||||
}
|
||||
|
||||
@@ -69,7 +74,8 @@ TEST_F(BridgingTest, callFromJsTest) {
|
||||
then.callWithThis(
|
||||
rt,
|
||||
promise,
|
||||
bridging::toJs(rt, [&](std::string res) { result = res; }, invoker));
|
||||
bridging::toJs(
|
||||
rt, [&](std::string res) { result = std::move(res); }, invoker));
|
||||
|
||||
flushQueue();
|
||||
EXPECT_EQ("hi"s, result);
|
||||
|
||||
+4
-1
@@ -7,6 +7,8 @@
|
||||
|
||||
#include "CxxTurboModuleUtils.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
namespace facebook::react {
|
||||
|
||||
std::unordered_map<
|
||||
@@ -26,7 +28,8 @@ void registerCxxModuleToGlobalModuleMap(
|
||||
std::string name,
|
||||
std::function<std::shared_ptr<TurboModule>(
|
||||
std::shared_ptr<CallInvoker> jsInvoker)> moduleProviderFunc) {
|
||||
globalExportedCxxTurboModuleMap()[name] = moduleProviderFunc;
|
||||
globalExportedCxxTurboModuleMap()[std::move(name)] =
|
||||
std::move(moduleProviderFunc);
|
||||
}
|
||||
|
||||
} // namespace facebook::react
|
||||
+3
-3
@@ -7,11 +7,11 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
|
||||
#include <ReactCommon/CallInvoker.h>
|
||||
#include <ReactCommon/TurboModule.h>
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
namespace facebook::react {
|
||||
|
||||
|
||||
+13
-14
@@ -20,10 +20,9 @@ namespace facebook::react {
|
||||
|
||||
namespace {
|
||||
CxxModule::Callback makeTurboCxxModuleCallback(
|
||||
jsi::Runtime& runtime,
|
||||
std::weak_ptr<CallbackWrapper> weakWrapper) {
|
||||
return [weakWrapper,
|
||||
wrapperWasCalled = false](std::vector<folly::dynamic> args) mutable {
|
||||
return [weakWrapper, wrapperWasCalled = false](
|
||||
const std::vector<folly::dynamic>& args) mutable {
|
||||
if (wrapperWasCalled) {
|
||||
LOG(FATAL) << "callback arg cannot be called more than once";
|
||||
}
|
||||
@@ -77,9 +76,9 @@ jsi::Value TurboCxxModule::create(
|
||||
0,
|
||||
[this](
|
||||
jsi::Runtime& rt,
|
||||
const jsi::Value& thisVal,
|
||||
const jsi::Value* args,
|
||||
size_t count) {
|
||||
const jsi::Value& /*thisVal*/,
|
||||
const jsi::Value* /*args*/,
|
||||
size_t /*count*/) {
|
||||
jsi::Object result(rt);
|
||||
auto constants = cxxModule_->getConstants();
|
||||
for (auto& pair : constants) {
|
||||
@@ -97,7 +96,7 @@ jsi::Value TurboCxxModule::create(
|
||||
0,
|
||||
[this, propNameUtf8](
|
||||
jsi::Runtime& rt,
|
||||
const jsi::Value& thisVal,
|
||||
const jsi::Value& /*thisVal*/,
|
||||
const jsi::Value* args,
|
||||
size_t count) {
|
||||
return invokeMethod(rt, propNameUtf8, args, count);
|
||||
@@ -114,8 +113,8 @@ std::vector<jsi::PropNameID> TurboCxxModule::getPropertyNames(
|
||||
std::vector<jsi::PropNameID> result;
|
||||
result.reserve(cxxMethods_.size() + 1);
|
||||
result.push_back(jsi::PropNameID::forUtf8(runtime, "getConstants"));
|
||||
for (auto it = cxxMethods_.begin(); it != cxxMethods_.end(); it++) {
|
||||
result.push_back(jsi::PropNameID::forUtf8(runtime, it->name));
|
||||
for (auto& cxxMethod : cxxMethods_) {
|
||||
result.push_back(jsi::PropNameID::forUtf8(runtime, cxxMethod.name));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -164,7 +163,7 @@ jsi::Value TurboCxxModule::invokeMethod(
|
||||
args[count - 1].getObject(runtime).getFunction(runtime),
|
||||
runtime,
|
||||
jsInvoker_);
|
||||
first = makeTurboCxxModuleCallback(runtime, wrapper);
|
||||
first = makeTurboCxxModuleCallback(wrapper);
|
||||
} else if (method.callbacks == 2) {
|
||||
auto wrapper1 = CallbackWrapper::createWeak(
|
||||
args[count - 2].getObject(runtime).getFunction(runtime),
|
||||
@@ -174,8 +173,8 @@ jsi::Value TurboCxxModule::invokeMethod(
|
||||
args[count - 1].getObject(runtime).getFunction(runtime),
|
||||
runtime,
|
||||
jsInvoker_);
|
||||
first = makeTurboCxxModuleCallback(runtime, wrapper1);
|
||||
second = makeTurboCxxModuleCallback(runtime, wrapper2);
|
||||
first = makeTurboCxxModuleCallback(wrapper1);
|
||||
second = makeTurboCxxModuleCallback(wrapper2);
|
||||
}
|
||||
|
||||
auto innerArgs = folly::dynamic::array();
|
||||
@@ -194,9 +193,9 @@ jsi::Value TurboCxxModule::invokeMethod(
|
||||
auto rejectWrapper = CallbackWrapper::createWeak(
|
||||
promise->reject_.getFunction(rt), rt, jsInvoker_);
|
||||
CxxModule::Callback resolve =
|
||||
makeTurboCxxModuleCallback(rt, resolveWrapper);
|
||||
makeTurboCxxModuleCallback(resolveWrapper);
|
||||
CxxModule::Callback reject =
|
||||
makeTurboCxxModuleCallback(rt, rejectWrapper);
|
||||
makeTurboCxxModuleCallback(rejectWrapper);
|
||||
|
||||
auto innerArgs = folly::dynamic::array();
|
||||
for (size_t i = 0; i < count; i++) {
|
||||
|
||||
+4
-3
@@ -13,7 +13,7 @@ namespace facebook::react {
|
||||
TurboModuleMethodValueKind getTurboModuleMethodValueKind(
|
||||
jsi::Runtime& rt,
|
||||
const jsi::Value* value) {
|
||||
if (!value || value->isUndefined() || value->isNull()) {
|
||||
if ((value == nullptr) || value->isUndefined() || value->isNull()) {
|
||||
return VoidKind;
|
||||
} else if (value->isBool()) {
|
||||
return BooleanKind;
|
||||
@@ -41,8 +41,9 @@ TurboModule::TurboModule(
|
||||
|
||||
void TurboModule::emitDeviceEvent(
|
||||
const std::string& eventName,
|
||||
ArgFactory argFactory) {
|
||||
jsInvoker_->invokeAsync([eventName, argFactory](jsi::Runtime& rt) {
|
||||
ArgFactory&& argFactory) {
|
||||
jsInvoker_->invokeAsync([eventName, argFactory = std::move(argFactory)](
|
||||
jsi::Runtime& rt) {
|
||||
jsi::Value emitter = rt.global().getProperty(rt, "__rctDeviceEventEmitter");
|
||||
if (!emitter.isUndefined()) {
|
||||
jsi::Object emitterObject = emitter.asObject(rt);
|
||||
|
||||
@@ -111,14 +111,14 @@ class JSI_EXPORT TurboModule : public jsi::HostObject {
|
||||
*/
|
||||
void emitDeviceEvent(
|
||||
const std::string& eventName,
|
||||
ArgFactory argFactory = nullptr);
|
||||
ArgFactory&& argFactory = nullptr);
|
||||
|
||||
// Backwards compatibility version
|
||||
void emitDeviceEvent(
|
||||
jsi::Runtime& /*runtime*/,
|
||||
|
||||
const std::string& eventName,
|
||||
ArgFactory argFactory = nullptr) {
|
||||
ArgFactory&& argFactory = nullptr) {
|
||||
emitDeviceEvent(eventName, std::move(argFactory));
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -54,7 +54,7 @@ class BridgelessNativeModuleProxy : public jsi::HostObject {
|
||||
*/
|
||||
std::string moduleName = name.utf8(runtime);
|
||||
if (moduleName == "__esModule") {
|
||||
return jsi::Value(false);
|
||||
return {false};
|
||||
}
|
||||
|
||||
auto turboModule = turboBinding_.getModule(runtime, moduleName);
|
||||
|
||||
+2
-2
@@ -35,9 +35,9 @@ jsi::Value createPromiseAsJSIValue(
|
||||
2,
|
||||
[func = std::move(func)](
|
||||
jsi::Runtime& rt2,
|
||||
const jsi::Value& thisVal,
|
||||
const jsi::Value& /*thisVal*/,
|
||||
const jsi::Value* args,
|
||||
size_t count) {
|
||||
size_t /*count*/) {
|
||||
jsi::Function resolve = args[0].getObject(rt2).getFunction(rt2);
|
||||
jsi::Function reject = args[1].getObject(rt2).getFunction(rt2);
|
||||
auto wrapper = std::make_shared<Promise>(
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@ struct Promise : public LongLivedObject {
|
||||
Promise(jsi::Runtime& rt, jsi::Function resolve, jsi::Function reject);
|
||||
|
||||
void resolve(const jsi::Value& result);
|
||||
void reject(const std::string& error);
|
||||
void reject(const std::string& message);
|
||||
|
||||
jsi::Function resolve_;
|
||||
jsi::Function reject_;
|
||||
|
||||
+5
-4
@@ -37,14 +37,15 @@ std::string getType(jsi::Runtime& rt, const jsi::Value& v) {
|
||||
|
||||
JavaInteropTurboModule::JavaInteropTurboModule(
|
||||
const JavaTurboModule::InitParams& params,
|
||||
std::vector<MethodDescriptor> methodDescriptors)
|
||||
const std::vector<MethodDescriptor>& methodDescriptors)
|
||||
: JavaTurboModule(params),
|
||||
methodDescriptors_(methodDescriptors),
|
||||
methodIDs_(methodDescriptors.size()),
|
||||
constantsCache_(jsi::Value::undefined()) {
|
||||
for (const auto& methodDescriptor : methodDescriptors) {
|
||||
methodMap_[methodDescriptor.methodName] = MethodMetadata{
|
||||
static_cast<size_t>(methodDescriptor.jsArgCount), nullptr};
|
||||
.argCount = static_cast<size_t>(methodDescriptor.jsArgCount),
|
||||
.invoker = nullptr};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,7 +61,7 @@ jsi::Value JavaInteropTurboModule::create(
|
||||
static_cast<unsigned int>(methodDescriptors_[i].jsArgCount),
|
||||
[this, i](
|
||||
jsi::Runtime& rt,
|
||||
const jsi::Value& thisVal,
|
||||
const jsi::Value& /*thisVal*/,
|
||||
const jsi::Value* args,
|
||||
size_t count) mutable {
|
||||
if (!this->constantsCache_.isUndefined()) {
|
||||
@@ -103,7 +104,7 @@ jsi::Value JavaInteropTurboModule::create(
|
||||
static_cast<unsigned int>(methodDescriptors_[i].jsArgCount),
|
||||
[this, i](
|
||||
jsi::Runtime& rt,
|
||||
const jsi::Value& thisVal,
|
||||
const jsi::Value& /*thisVal*/,
|
||||
const jsi::Value* args,
|
||||
size_t count) {
|
||||
return this->invokeJavaMethod(
|
||||
|
||||
+1
-1
@@ -29,7 +29,7 @@ class JSI_EXPORT JavaInteropTurboModule : public JavaTurboModule {
|
||||
|
||||
JavaInteropTurboModule(
|
||||
const JavaTurboModule::InitParams& params,
|
||||
std::vector<MethodDescriptor> methodDescriptors);
|
||||
const std::vector<MethodDescriptor>& methodDescriptors);
|
||||
|
||||
std::vector<facebook::jsi::PropNameID> getPropertyNames(
|
||||
facebook::jsi::Runtime& runtime) override;
|
||||
|
||||
+11
-11
@@ -521,7 +521,7 @@ jsi::Value JavaTurboModule::invokeJavaMethod(
|
||||
const char* methodName = methodNameStr.c_str();
|
||||
const char* moduleName = name_.c_str();
|
||||
|
||||
bool isMethodSync = !(valueKind == VoidKind || valueKind == PromiseKind);
|
||||
bool isMethodSync = valueKind != VoidKind && valueKind != PromiseKind;
|
||||
|
||||
if (isMethodSync) {
|
||||
TMPL::syncMethodCallStart(moduleName, methodName);
|
||||
@@ -582,7 +582,7 @@ jsi::Value JavaTurboModule::invokeJavaMethod(
|
||||
}
|
||||
};
|
||||
|
||||
if (!methodID) {
|
||||
if (methodID == nullptr) {
|
||||
jclass cls = env->GetObjectClass(instance);
|
||||
methodID = env->GetMethodID(cls, methodName, methodSignature.c_str());
|
||||
|
||||
@@ -645,7 +645,7 @@ jsi::Value JavaTurboModule::invokeJavaMethod(
|
||||
TMPL::syncMethodCallReturnConversionStart(moduleName, methodName);
|
||||
|
||||
auto returnValue = jsi::Value::null();
|
||||
if (returnObject) {
|
||||
if (returnObject != nullptr) {
|
||||
auto booleanObj = jni::adopt_local(
|
||||
static_cast<jni::JBoolean::javaobject>(returnObject));
|
||||
returnValue = jsi::Value(static_cast<bool>(booleanObj->value()));
|
||||
@@ -684,7 +684,7 @@ jsi::Value JavaTurboModule::invokeJavaMethod(
|
||||
TMPL::syncMethodCallReturnConversionStart(moduleName, methodName);
|
||||
|
||||
auto returnValue = jsi::Value::null();
|
||||
if (returnObject) {
|
||||
if (returnObject != nullptr) {
|
||||
if (returnType == "Ljava/lang/Double;") {
|
||||
auto doubleObj = jni::adopt_local(
|
||||
static_cast<jni::JDouble::javaobject>(returnObject));
|
||||
@@ -706,8 +706,8 @@ jsi::Value JavaTurboModule::invokeJavaMethod(
|
||||
} else if (returnType == "D" || returnType == "F" || returnType == "I") {
|
||||
jsi::Value returnValue = jsi::Value::undefined();
|
||||
if (returnType == "D") {
|
||||
double returnDouble =
|
||||
(double)env->CallDoubleMethodA(instance, methodID, jargs.data());
|
||||
auto returnDouble = static_cast<double>(
|
||||
env->CallDoubleMethodA(instance, methodID, jargs.data()));
|
||||
checkJNIErrorForMethodCall();
|
||||
|
||||
TMPL::syncMethodCallExecutionEnd(moduleName, methodName);
|
||||
@@ -715,8 +715,8 @@ jsi::Value JavaTurboModule::invokeJavaMethod(
|
||||
|
||||
returnValue = jsi::Value(returnDouble);
|
||||
} else if (returnType == "F") {
|
||||
float returnFloat =
|
||||
(float)env->CallFloatMethodA(instance, methodID, jargs.data());
|
||||
auto returnFloat = static_cast<float>(
|
||||
env->CallFloatMethodA(instance, methodID, jargs.data()));
|
||||
checkJNIErrorForMethodCall();
|
||||
|
||||
TMPL::syncMethodCallExecutionEnd(moduleName, methodName);
|
||||
@@ -724,8 +724,8 @@ jsi::Value JavaTurboModule::invokeJavaMethod(
|
||||
|
||||
returnValue = jsi::Value((double)returnFloat);
|
||||
} else if (returnType == "I") {
|
||||
int returnInt =
|
||||
(int)env->CallIntMethodA(instance, methodID, jargs.data());
|
||||
int returnInt = static_cast<int>(
|
||||
env->CallIntMethodA(instance, methodID, jargs.data()));
|
||||
checkJNIErrorForMethodCall();
|
||||
|
||||
TMPL::syncMethodCallExecutionEnd(moduleName, methodName);
|
||||
@@ -858,7 +858,7 @@ jsi::Value JavaTurboModule::invokeJavaMethod(
|
||||
std::optional<AsyncCallback<>> nativeRejectCallback;
|
||||
|
||||
// The promise constructor runs its arg immediately, so this is safe
|
||||
jobject javaPromise;
|
||||
jobject javaPromise = nullptr;
|
||||
jsi::Value jsPromise = Promise.callAsConstructor(
|
||||
runtime,
|
||||
jsi::Function::createFromHostFunction(
|
||||
|
||||
@@ -299,7 +299,7 @@ NativeDOM::getScrollSize(
|
||||
}
|
||||
|
||||
std::string NativeDOM::getTagName(
|
||||
jsi::Runtime& rt,
|
||||
jsi::Runtime& /*rt*/,
|
||||
std::shared_ptr<const ShadowNode> shadowNode) {
|
||||
return dom::getTagName(*shadowNode);
|
||||
}
|
||||
|
||||
+1
-1
@@ -28,7 +28,7 @@ namespace {
|
||||
|
||||
class IdleTaskRef : public jsi::NativeState {
|
||||
public:
|
||||
IdleTaskRef(std::shared_ptr<Task> task) : task(std::move(task)) {}
|
||||
explicit IdleTaskRef(std::shared_ptr<Task> task) : task(std::move(task)) {}
|
||||
|
||||
std::shared_ptr<Task> task;
|
||||
};
|
||||
|
||||
+2
-2
@@ -35,7 +35,7 @@ NativeMutationObserver::NativeMutationObserver(
|
||||
|
||||
void NativeMutationObserver::observe(
|
||||
jsi::Runtime& runtime,
|
||||
NativeMutationObserverObserveOptions options) {
|
||||
const NativeMutationObserverObserveOptions& options) {
|
||||
auto mutationObserverId = options.mutationObserverId;
|
||||
auto subtree = options.subtree;
|
||||
auto shadowNode = options.targetShadowNode;
|
||||
@@ -46,7 +46,7 @@ void NativeMutationObserver::observe(
|
||||
}
|
||||
|
||||
void NativeMutationObserver::unobserveAll(
|
||||
jsi::Runtime& runtime,
|
||||
jsi::Runtime& /*runtime*/,
|
||||
MutationObserverId mutationObserverId) {
|
||||
mutationObserverManager_.unobserveAll(mutationObserverId);
|
||||
}
|
||||
|
||||
+1
-1
@@ -51,7 +51,7 @@ class NativeMutationObserver
|
||||
|
||||
void observe(
|
||||
jsi::Runtime& runtime,
|
||||
NativeMutationObserverObserveOptions options);
|
||||
const NativeMutationObserverObserveOptions& options);
|
||||
|
||||
void unobserveAll(
|
||||
jsi::Runtime& runtime,
|
||||
|
||||
+47
-25
@@ -332,45 +332,67 @@ NativeSampleTurboModuleSpecJSI::NativeSampleTurboModuleSpecJSI(
|
||||
const JavaTurboModule::InitParams& params)
|
||||
: JavaTurboModule(params) {
|
||||
methodMap_["getConstants"] = MethodMetadata{
|
||||
0, __hostFunction_NativeSampleTurboModuleSpecJSI_getConstants};
|
||||
methodMap_["voidFunc"] =
|
||||
MethodMetadata{0, __hostFunction_NativeSampleTurboModuleSpecJSI_voidFunc};
|
||||
methodMap_["getBool"] =
|
||||
MethodMetadata{1, __hostFunction_NativeSampleTurboModuleSpecJSI_getBool};
|
||||
methodMap_["getEnum"] =
|
||||
MethodMetadata{1, __hostFunction_NativeSampleTurboModuleSpecJSI_getEnum};
|
||||
.argCount = 0,
|
||||
.invoker = __hostFunction_NativeSampleTurboModuleSpecJSI_getConstants};
|
||||
methodMap_["voidFunc"] = MethodMetadata{
|
||||
.argCount = 0,
|
||||
.invoker = __hostFunction_NativeSampleTurboModuleSpecJSI_voidFunc};
|
||||
methodMap_["getBool"] = MethodMetadata{
|
||||
.argCount = 1,
|
||||
.invoker = __hostFunction_NativeSampleTurboModuleSpecJSI_getBool};
|
||||
methodMap_["getEnum"] = MethodMetadata{
|
||||
.argCount = 1,
|
||||
.invoker = __hostFunction_NativeSampleTurboModuleSpecJSI_getEnum};
|
||||
methodMap_["getNumber"] = MethodMetadata{
|
||||
1, __hostFunction_NativeSampleTurboModuleSpecJSI_getNumber};
|
||||
.argCount = 1,
|
||||
.invoker = __hostFunction_NativeSampleTurboModuleSpecJSI_getNumber};
|
||||
methodMap_["getString"] = MethodMetadata{
|
||||
1, __hostFunction_NativeSampleTurboModuleSpecJSI_getString};
|
||||
methodMap_["getArray"] =
|
||||
MethodMetadata{1, __hostFunction_NativeSampleTurboModuleSpecJSI_getArray};
|
||||
.argCount = 1,
|
||||
.invoker = __hostFunction_NativeSampleTurboModuleSpecJSI_getString};
|
||||
methodMap_["getArray"] = MethodMetadata{
|
||||
.argCount = 1,
|
||||
.invoker = __hostFunction_NativeSampleTurboModuleSpecJSI_getArray};
|
||||
methodMap_["getObject"] = MethodMetadata{
|
||||
1, __hostFunction_NativeSampleTurboModuleSpecJSI_getObject};
|
||||
.argCount = 1,
|
||||
.invoker = __hostFunction_NativeSampleTurboModuleSpecJSI_getObject};
|
||||
methodMap_["getUnsafeObject"] = MethodMetadata{
|
||||
1, __hostFunction_NativeSampleTurboModuleSpecJSI_getUnsafeObject};
|
||||
.argCount = 1,
|
||||
.invoker = __hostFunction_NativeSampleTurboModuleSpecJSI_getUnsafeObject};
|
||||
methodMap_["getRootTag"] = MethodMetadata{
|
||||
1, __hostFunction_NativeSampleTurboModuleSpecJSI_getRootTag};
|
||||
methodMap_["getValue"] =
|
||||
MethodMetadata{3, __hostFunction_NativeSampleTurboModuleSpecJSI_getValue};
|
||||
.argCount = 1,
|
||||
.invoker = __hostFunction_NativeSampleTurboModuleSpecJSI_getRootTag};
|
||||
methodMap_["getValue"] = MethodMetadata{
|
||||
.argCount = 3,
|
||||
.invoker = __hostFunction_NativeSampleTurboModuleSpecJSI_getValue};
|
||||
methodMap_["getValueWithCallback"] = MethodMetadata{
|
||||
1, __hostFunction_NativeSampleTurboModuleSpecJSI_getValueWithCallback};
|
||||
.argCount = 1,
|
||||
.invoker =
|
||||
__hostFunction_NativeSampleTurboModuleSpecJSI_getValueWithCallback};
|
||||
methodMap_["getValueWithPromise"] = MethodMetadata{
|
||||
1, __hostFunction_NativeSampleTurboModuleSpecJSI_getValueWithPromise};
|
||||
.argCount = 1,
|
||||
.invoker =
|
||||
__hostFunction_NativeSampleTurboModuleSpecJSI_getValueWithPromise};
|
||||
methodMap_["voidFuncThrows"] = MethodMetadata{
|
||||
0, __hostFunction_NativeSampleTurboModuleSpecJSI_voidFuncThrows};
|
||||
.argCount = 0,
|
||||
.invoker = __hostFunction_NativeSampleTurboModuleSpecJSI_voidFuncThrows};
|
||||
methodMap_["getObjectThrows"] = MethodMetadata{
|
||||
1, __hostFunction_NativeSampleTurboModuleSpecJSI_getObjectThrows};
|
||||
.argCount = 1,
|
||||
.invoker = __hostFunction_NativeSampleTurboModuleSpecJSI_getObjectThrows};
|
||||
methodMap_["promiseThrows"] = MethodMetadata{
|
||||
0, __hostFunction_NativeSampleTurboModuleSpecJSI_promiseThrows};
|
||||
.argCount = 0,
|
||||
.invoker = __hostFunction_NativeSampleTurboModuleSpecJSI_promiseThrows};
|
||||
methodMap_["voidFuncAssert"] = MethodMetadata{
|
||||
0, __hostFunction_NativeSampleTurboModuleSpecJSI_voidFuncAssert};
|
||||
.argCount = 0,
|
||||
.invoker = __hostFunction_NativeSampleTurboModuleSpecJSI_voidFuncAssert};
|
||||
methodMap_["getObjectAssert"] = MethodMetadata{
|
||||
1, __hostFunction_NativeSampleTurboModuleSpecJSI_getObjectAssert};
|
||||
.argCount = 1,
|
||||
.invoker = __hostFunction_NativeSampleTurboModuleSpecJSI_getObjectAssert};
|
||||
methodMap_["promiseAssert"] = MethodMetadata{
|
||||
0, __hostFunction_NativeSampleTurboModuleSpecJSI_promiseAssert};
|
||||
.argCount = 0,
|
||||
.invoker = __hostFunction_NativeSampleTurboModuleSpecJSI_promiseAssert};
|
||||
methodMap_["getImageUrl"] = MethodMetadata{
|
||||
0, __hostFunction_NativeSampleTurboModuleSpecJSI_getImageUrl};
|
||||
.argCount = 0,
|
||||
.invoker = __hostFunction_NativeSampleTurboModuleSpecJSI_getImageUrl};
|
||||
eventEmitterMap_["onPress"] =
|
||||
std::make_shared<AsyncEventEmitter<folly::dynamic>>();
|
||||
eventEmitterMap_["onClick"] =
|
||||
|
||||
+6
-6
@@ -136,7 +136,7 @@ HighResTimeStamp NativePerformance::now(jsi::Runtime& /*rt*/) {
|
||||
|
||||
void NativePerformance::reportMark(
|
||||
jsi::Runtime& rt,
|
||||
std::string name,
|
||||
const std::string& name,
|
||||
HighResTimeStamp startTime,
|
||||
jsi::Value entry) {
|
||||
PerformanceEntryReporter::getInstance()->reportMark(
|
||||
@@ -145,7 +145,7 @@ void NativePerformance::reportMark(
|
||||
|
||||
void NativePerformance::reportMeasure(
|
||||
jsi::Runtime& rt,
|
||||
std::string name,
|
||||
const std::string& name,
|
||||
HighResTimeStamp startTime,
|
||||
HighResDuration duration,
|
||||
jsi::Value entry) {
|
||||
@@ -154,8 +154,8 @@ void NativePerformance::reportMeasure(
|
||||
}
|
||||
|
||||
std::optional<double> NativePerformance::getMarkTime(
|
||||
jsi::Runtime& rt,
|
||||
std::string name) {
|
||||
jsi::Runtime& /*rt*/,
|
||||
const std::string& name) {
|
||||
auto markTime = PerformanceEntryReporter::getInstance()->getMarkTime(name);
|
||||
return markTime ? std::optional{(*markTime).toDOMHighResTimeStamp()}
|
||||
: std::nullopt;
|
||||
@@ -200,7 +200,7 @@ std::vector<NativePerformanceEntry> NativePerformance::getEntries(
|
||||
|
||||
std::vector<NativePerformanceEntry> NativePerformance::getEntriesByName(
|
||||
jsi::Runtime& /*rt*/,
|
||||
std::string entryName,
|
||||
const std::string& entryName,
|
||||
std::optional<PerformanceEntryType> entryType) {
|
||||
std::vector<PerformanceEntry> entries;
|
||||
|
||||
@@ -253,7 +253,7 @@ std::unordered_map<std::string, double> NativePerformance::getSimpleMemoryInfo(
|
||||
}
|
||||
|
||||
std::unordered_map<std::string, double>
|
||||
NativePerformance::getReactNativeStartupTiming(jsi::Runtime& rt) {
|
||||
NativePerformance::getReactNativeStartupTiming(jsi::Runtime& /*rt*/) {
|
||||
std::unordered_map<std::string, double> result;
|
||||
|
||||
ReactMarker::StartupLogger& startupLogger =
|
||||
|
||||
+4
-4
@@ -92,18 +92,18 @@ class NativePerformance : public NativePerformanceCxxSpec<NativePerformance> {
|
||||
|
||||
void reportMark(
|
||||
jsi::Runtime& rt,
|
||||
std::string name,
|
||||
const std::string& name,
|
||||
HighResTimeStamp time,
|
||||
jsi::Value entry);
|
||||
|
||||
void reportMeasure(
|
||||
jsi::Runtime& rt,
|
||||
std::string name,
|
||||
const std::string& name,
|
||||
HighResTimeStamp startTime,
|
||||
HighResDuration duration,
|
||||
jsi::Value entry);
|
||||
|
||||
std::optional<double> getMarkTime(jsi::Runtime& rt, std::string name);
|
||||
std::optional<double> getMarkTime(jsi::Runtime& rt, const std::string& name);
|
||||
|
||||
// https://w3c.github.io/user-timing/#clearmarks-method
|
||||
void clearMarks(
|
||||
@@ -128,7 +128,7 @@ class NativePerformance : public NativePerformanceCxxSpec<NativePerformance> {
|
||||
// https://www.w3.org/TR/performance-timeline/#getentriesbyname-method
|
||||
std::vector<NativePerformanceEntry> getEntriesByName(
|
||||
jsi::Runtime& rt,
|
||||
std::string entryName,
|
||||
const std::string& entryName,
|
||||
std::optional<PerformanceEntryType> entryType = std::nullopt);
|
||||
|
||||
#pragma mark - Performance Observer (https://w3c.github.io/performance-timeline/#the-performanceobserver-interface)
|
||||
|
||||
+1
-3
@@ -33,9 +33,7 @@ void PerformanceEntryKeyedBuffer::getEntries(
|
||||
void PerformanceEntryKeyedBuffer::getEntries(
|
||||
std::vector<PerformanceEntry>& target,
|
||||
const std::string& name) const {
|
||||
std::string nameStr{name};
|
||||
|
||||
if (auto node = entryMap_.find(nameStr); node != entryMap_.end()) {
|
||||
if (auto node = entryMap_.find(name); node != entryMap_.end()) {
|
||||
target.insert(target.end(), node->second.begin(), node->second.end());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user