Skip to content

Commit

Permalink
clang-format cpp
Browse files Browse the repository at this point in the history
Summary:
Ran `arc f` against some CPP files to be modified with the next diff
to reduce the churn on it.

## Changelog

[Android] [Changed] - Formatted cpp/h code with clang-format

Reviewed By: javache

Differential Revision: D19371785

fbshipit-source-id: b7f7b92c4cb9ec7f8da728bb577db29cf11fbb39
  • Loading branch information
passy authored and facebook-github-bot committed Jan 14, 2020
1 parent 8d57691 commit d5ba113
Show file tree
Hide file tree
Showing 44 changed files with 924 additions and 658 deletions.
221 changes: 134 additions & 87 deletions ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Binding.cpp

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,17 @@ class Binding : public jni::HybridClass<Binding>, public SchedulerDelegate {
const ShadowView &shadowView);

void schedulerDidDispatchCommand(
const ShadowView &shadowView,
std::string const &commandName,
folly::dynamic const args);
const ShadowView &shadowView,
std::string const &commandName,
folly::dynamic const args);

void setPixelDensity(float pointScaleFactor);

void schedulerDidSetJSResponder(
SurfaceId surfaceId,
const ShadowView &shadowView,
const ShadowView &initialShadowView,
bool blockNativeResponder);
SurfaceId surfaceId,
const ShadowView &shadowView,
const ShadowView &initialShadowView,
bool blockNativeResponder);

void schedulerDidClearJSResponder();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
#include <fb/fbjni.h>
#include <jsi/jsi.h>
#include <react/uimanager/ComponentDescriptorRegistry.h>
#include <react/utils/ContextContainer.h>
#include <react/uimanager/Scheduler.h>
#include <react/utils/ContextContainer.h>
#include <mutex>
#include <unordered_set>

Expand All @@ -25,7 +25,7 @@ class Instance;
class ComponentFactoryDelegate
: public jni::HybridClass<ComponentFactoryDelegate> {
public:
constexpr static const char* const kJavaDescriptor =
constexpr static const char *const kJavaDescriptor =
"Lcom/facebook/react/fabric/ComponentFactoryDelegate;";

static void registerNatives();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ namespace facebook {
namespace react {

EventBeatManager::EventBeatManager(
jni::alias_ref<EventBeatManager::jhybriddata> jhybridobject)
: jhybridobject_(jhybridobject) {}
jni::alias_ref<EventBeatManager::jhybriddata> jhybridobject)
: jhybridobject_(jhybridobject) {}

jni::local_ref<EventBeatManager::jhybriddata> EventBeatManager::initHybrid(
jni::alias_ref<EventBeatManager::jhybriddata> jhybridobject) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ EventEmitterWrapper::initHybrid(jni::alias_ref<jclass>) {

void EventEmitterWrapper::invokeEvent(
std::string eventName,
NativeMap* payload) {
NativeMap *payload) {
eventEmitter->dispatchEvent(
eventName, payload->consume(), EventPriority::AsynchronousBatched);
}
Expand All @@ -33,4 +33,4 @@ void EventEmitterWrapper::registerNatives() {
}

} // namespace react
} // namespace facebook
} // namespace facebook
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ class Instance;

class EventEmitterWrapper : public jni::HybridClass<EventEmitterWrapper> {
public:
constexpr static const char* const kJavaDescriptor =
constexpr static const char *const kJavaDescriptor =
"Lcom/facebook/react/fabric/events/EventEmitterWrapper;";

static void registerNatives();

SharedEventEmitter eventEmitter;

void invokeEvent(std::string eventName, NativeMap* params);
void invokeEvent(std::string eventName, NativeMap *params);

private:
static jni::local_ref<jhybriddata> initHybrid(jni::alias_ref<jclass>);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ using namespace facebook::jni;
namespace facebook {
namespace react {

jni::local_ref<NodeStateWrapper::jhybriddata>
NodeStateWrapper::initHybrid(jni::alias_ref<jclass>) {
jni::local_ref<NodeStateWrapper::jhybriddata> NodeStateWrapper::initHybrid(
jni::alias_ref<jclass>) {
return makeCxxInstance();
}

Expand All @@ -26,7 +26,7 @@ jni::local_ref<ReadableNativeMap::jhybridobject> NodeStateWrapper::getState() {
return readableNativeMap;
}

void NodeStateWrapper::updateState(ReadableNativeMap* map) {
void NodeStateWrapper::updateState(ReadableNativeMap *map) {
// Get folly::dynamic from map
auto dynamicMap = map->consume();
// Set state
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,18 @@ namespace react {

class NodeStateWrapper : public jni::HybridClass<NodeStateWrapper> {
public:
constexpr static const char* const kJavaDescriptor =
constexpr static const char *const kJavaDescriptor =
"Lcom/facebook/react/fabric/NodeStateWrapper;";

NodeStateWrapper() {}

static void registerNatives();

jni::local_ref<ReadableNativeMap::jhybridobject> getState();
void updateState(ReadableNativeMap* map);
void updateState(ReadableNativeMap *map);

const State *state_;

const State* state_;
private:
static jni::local_ref<jhybriddata> initHybrid(jni::alias_ref<jclass>);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include "EventEmitterWrapper.h"
#include "StateWrapperImpl.h"

JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void*) {
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *) {
return facebook::xplat::initialize(vm, [] {
facebook::react::Binding::registerNatives();
facebook::react::EventBeatManager::registerNatives();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,29 @@

using namespace facebook::react;

bool ReactNativeConfigHolder::getBool(const std::string& param) const {
bool ReactNativeConfigHolder::getBool(const std::string &param) const {
static const auto method = facebook::jni::findClassStatic(
"com/facebook/react/fabric/ReactNativeConfig")
->getMethod<jboolean(jstring)>("getBool");
return method(reactNativeConfig_, facebook::jni::make_jstring(param).get());
}

std::string ReactNativeConfigHolder::getString(const std::string& param) const {
std::string ReactNativeConfigHolder::getString(const std::string &param) const {
static const auto method = facebook::jni::findClassStatic(
"com/facebook/react/fabric/ReactNativeConfig")
->getMethod<jstring(jstring)>("getString");
return method(reactNativeConfig_, facebook::jni::make_jstring(param).get())
->toString();
}

int64_t ReactNativeConfigHolder::getInt64(const std::string& param) const {
int64_t ReactNativeConfigHolder::getInt64(const std::string &param) const {
static const auto method = facebook::jni::findClassStatic(
"com/facebook/react/fabric/ReactNativeConfig")
->getMethod<jint(jstring)>("getInt64");
return method(reactNativeConfig_, facebook::jni::make_jstring(param).get());
}

double ReactNativeConfigHolder::getDouble(const std::string& param) const {
double ReactNativeConfigHolder::getDouble(const std::string &param) const {
static const auto method = facebook::jni::findClassStatic(
"com/facebook/react/fabric/ReactNativeConfig")
->getMethod<jdouble(jstring)>("getDouble");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ class ReactNativeConfigHolder : public ReactNativeConfig {
ReactNativeConfigHolder(jni::alias_ref<jobject> reactNativeConfig)
: reactNativeConfig_(make_global(reactNativeConfig)){};

bool getBool(const std::string& param) const override;
std::string getString(const std::string& param) const override;
int64_t getInt64(const std::string& param) const override;
double getDouble(const std::string& param) const override;
bool getBool(const std::string &param) const override;
std::string getString(const std::string &param) const override;
int64_t getInt64(const std::string &param) const override;
double getDouble(const std::string &param) const override;

private:
jni::global_ref<jobject> reactNativeConfig_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ namespace react {
/**
* Called from Java constructor through the JNI.
*/
jni::local_ref<StateWrapperImpl::jhybriddata>
StateWrapperImpl::initHybrid(jni::alias_ref<jclass>) {
jni::local_ref<StateWrapperImpl::jhybriddata> StateWrapperImpl::initHybrid(
jni::alias_ref<jclass>) {
return makeCxxInstance();
}

Expand All @@ -29,7 +29,7 @@ jni::local_ref<ReadableNativeMap::jhybridobject> StateWrapperImpl::getState() {
return readableNativeMap;
}

void StateWrapperImpl::updateStateImpl(NativeMap* map) {
void StateWrapperImpl::updateStateImpl(NativeMap *map) {
// Get folly::dynamic from map
auto dynamicMap = map->consume();
// Set state
Expand All @@ -38,8 +38,8 @@ void StateWrapperImpl::updateStateImpl(NativeMap* map) {

void StateWrapperImpl::registerNatives() {
registerHybrid({
makeNativeMethod("initHybrid", StateWrapperImpl::initHybrid),
makeNativeMethod("getState", StateWrapperImpl::getState),
makeNativeMethod("initHybrid", StateWrapperImpl::initHybrid),
makeNativeMethod("getState", StateWrapperImpl::getState),
makeNativeMethod("updateStateImpl", StateWrapperImpl::updateStateImpl),
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Instance;

class StateWrapperImpl : public jni::HybridClass<StateWrapperImpl> {
public:
constexpr static const char* const kJavaDescriptor =
constexpr static const char *const kJavaDescriptor =
"Lcom/facebook/react/fabric/StateWrapperImpl;";

static void registerNatives();
Expand All @@ -27,6 +27,7 @@ class StateWrapperImpl : public jni::HybridClass<StateWrapperImpl> {
void updateStateImpl(NativeMap *map);

State::Shared state_;

private:
jni::alias_ref<StateWrapperImpl::jhybriddata> jhybridobject_;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ BlobCollector::BlobCollector(
BlobCollector::~BlobCollector() {
jni::ThreadScope::WithClassLoader([&] {
static auto removeMethod = jni::findClassStatic(kBlobModuleJavaDescriptor)
->getMethod<void(jstring)>("remove");
->getMethod<void(jstring)>("remove");
removeMethod(blobModule_, jni::make_jstring(blobId_).get());
});
}
Expand All @@ -36,7 +36,7 @@ void BlobCollector::nativeInstall(
jni::alias_ref<jhybridobject> jThis,
jni::alias_ref<jobject> blobModule,
jlong jsContextNativePointer) {
auto &runtime = *((jsi::Runtime *) jsContextNativePointer);
auto &runtime = *((jsi::Runtime *)jsContextNativePointer);
auto blobModuleRef = jni::make_global(blobModule);
runtime.global().setProperty(
runtime,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,14 @@

#pragma once

#include <fb/fbjni.h>
#include <ReactCommon/CallInvoker.h>
#include <fb/fbjni.h>
#include <memory>

namespace facebook {
namespace react {

class CallInvokerHolder
: public jni::HybridClass<CallInvokerHolder> {
class CallInvokerHolder : public jni::HybridClass<CallInvokerHolder> {
public:
static auto constexpr kJavaDescriptor =
"Lcom/facebook/react/turbomodule/core/CallInvokerHolderImpl;";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@

JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *) {
return facebook::xplat::initialize(vm, [] {
// TODO: dvacca ramanpreet unify this with the way "ComponentDescriptorFactory" is defined in Fabric
// TODO: dvacca ramanpreet unify this with the way
// "ComponentDescriptorFactory" is defined in Fabric
facebook::react::TurboModuleManager::registerNatives();
});
}
Loading

0 comments on commit d5ba113

Please sign in to comment.