Skip to content

Commit

Permalink
Use fbsource clang-format config
Browse files Browse the repository at this point in the history
Summary:
This mirrors the clang-format config used by fbsource to Yoga.

They are pretty similar, except for an annoying habit where Yoga's previous forced small functions in headers to be a a single line, so you would get a combination of multiline and single line functions next to each other which are hard to read. That is what motivated this change.

It also enforces header ordering (yay). I don't think we have any side-effect causing headers, so this should be safe.

Reviewed By: yungsters

Differential Revision: D49248994

fbshipit-source-id: 66998395e7c0158ff9d9fb1bee44e8401bdd8f21
  • Loading branch information
NickGerleman authored and facebook-github-bot committed Sep 14, 2023
1 parent 7f78fa2 commit b29b393
Show file tree
Hide file tree
Showing 30 changed files with 430 additions and 311 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace facebook::yoga::vanillajni {

// TODO: This should not be exported or used outside of the JNI bindings
class YG_EXPORT LayoutContext {
public:
public:
// Sets a context on the current thread for the duration of the Provider's
// lifetime. This context should be set during the layout process to allow
// layout callbacks to access context-data specific to the layout pass.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class ScopedGlobalRef {
std::is_same<T, jbooleanArray>(),
"ScopedGlobalRef instantiated for invalid type");

public:
public:
/**
* Constructs a ScopedGlobalRef with a JNI global reference.
*
Expand All @@ -82,7 +82,9 @@ class ScopedGlobalRef {
return *this;
}

~ScopedGlobalRef() { reset(); }
~ScopedGlobalRef() {
reset();
}

/**
* Deletes the currently held reference and reassigns a new one to the
Expand Down Expand Up @@ -111,17 +113,21 @@ class ScopedGlobalRef {
/**
* Returns the underlying JNI global reference.
*/
T get() const { return mGlobalRef; }
T get() const {
return mGlobalRef;
}

/**
* Returns true if the underlying JNI reference is not NULL.
*/
operator bool() const { return mGlobalRef != NULL; }
operator bool() const {
return mGlobalRef != NULL;
}

ScopedGlobalRef(const ScopedGlobalRef& ref) = delete;
ScopedGlobalRef& operator=(const ScopedGlobalRef& other) = delete;

private:
private:
T mGlobalRef;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class ScopedLocalRef {
std::is_same<T, jbooleanArray>(),
"ScopedLocalRef instantiated for invalid type");

public:
public:
/**
* Constructs a ScopedLocalRef with a JNI local reference.
*
Expand All @@ -81,7 +81,9 @@ class ScopedLocalRef {
return *this;
}

~ScopedLocalRef() { reset(); }
~ScopedLocalRef() {
reset();
}

/**
* Deletes the currently held reference and reassigns a new one to the
Expand Down Expand Up @@ -110,17 +112,21 @@ class ScopedLocalRef {
/**
* Returns the underlying JNI local reference.
*/
T get() const { return mLocalRef; }
T get() const {
return mLocalRef;
}

/**
* Returns true if the underlying JNI reference is not NULL.
*/
operator bool() const { return mLocalRef != NULL; }
operator bool() const {
return mLocalRef != NULL;
}

ScopedLocalRef(const ScopedLocalRef& ref) = delete;
ScopedLocalRef& operator=(const ScopedLocalRef& other) = delete;

private:
private:
JNIEnv* mEnv;
T mLocalRef;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ union YGNodeContext {
class YGNodeEdges {
int32_t edges_;

public:
public:
enum Edge {
MARGIN = 1,
PADDING = 2,
Expand All @@ -48,14 +48,18 @@ class YGNodeEdges {
YGNodeSetContext(node, context.asVoidPtr);
}

bool has(Edge edge) { return (edges_ & edge) == edge; }
bool has(Edge edge) {
return (edges_ & edge) == edge;
}

YGNodeEdges& add(Edge edge) {
edges_ |= edge;
return *this;
}

int get() { return edges_; }
int get() {
return edges_;
}
};

struct YogaValue {
Expand All @@ -64,10 +68,10 @@ struct YogaValue {
static jlong asJavaLong(const YGValue& value) {
uint32_t valueBytes = 0;
memcpy(&valueBytes, &value.value, sizeof valueBytes);
return ((jlong) value.unit) << 32 | valueBytes;
return ((jlong)value.unit) << 32 | valueBytes;
}
constexpr static jlong undefinedAsJavaLong() {
return ((jlong) YGUnitUndefined) << 32 | NAN_BYTES;
return ((jlong)YGUnitUndefined) << 32 | NAN_BYTES;
}
};
} // namespace
Loading

0 comments on commit b29b393

Please sign in to comment.