From 09f0869262e50b90837688ef37ff84cc38b799be Mon Sep 17 00:00:00 2001 From: Nick Gerleman Date: Thu, 22 Dec 2022 03:59:36 -0800 Subject: [PATCH] clang-format the JS directory --- .github/actions/clang-format/action.yml | 2 +- .github/workflows/validate-cpp.yml | 5 + javascript/sources/Node.cc | 4 +- javascript/sources/Node.hh | 15 +- javascript/sources/Value.hh | 2 +- javascript/sources/embind.cc | 237 ++++++++++++------------ 6 files changed, 133 insertions(+), 132 deletions(-) diff --git a/.github/actions/clang-format/action.yml b/.github/actions/clang-format/action.yml index a0d52af2..79508a14 100644 --- a/.github/actions/clang-format/action.yml +++ b/.github/actions/clang-format/action.yml @@ -21,4 +21,4 @@ runs: run: | shopt -s globstar shopt -s nullglob - clang-format-${{ inputs.version }} --dry-run --Werror **/*.cpp **/*.h **/*.m **/*.mm + clang-format-${{ inputs.version }} --dry-run --Werror **/*.cpp **/*.cc **/*.h **/*.hh **/*.m **/*.mm diff --git a/.github/workflows/validate-cpp.yml b/.github/workflows/validate-cpp.yml index 3f4b4e7a..121bdb41 100644 --- a/.github/workflows/validate-cpp.yml +++ b/.github/workflows/validate-cpp.yml @@ -19,3 +19,8 @@ jobs: uses: ./.github/actions/clang-format with: directory: ./yoga + + - name: clang-format (JavaScript Bindings) + uses: ./.github/actions/clang-format + with: + directory: ./javascript diff --git a/javascript/sources/Node.cc b/javascript/sources/Node.cc index 7c71091a..daadf753 100644 --- a/javascript/sources/Node.cc +++ b/javascript/sources/Node.cc @@ -369,7 +369,7 @@ Node* Node::getChild(unsigned index) { return Node::fromYGNode(nodePtr); } -void Node::setMeasureFunc(MeasureCallback *measureFunc) { +void Node::setMeasureFunc(MeasureCallback* measureFunc) { m_measureFunc.reset(measureFunc); YGNodeSetMeasureFunc(m_node, &globalMeasureFunc); @@ -389,7 +389,7 @@ Size Node::callMeasureFunc( return m_measureFunc->measure(width, widthMode, height, heightMode); } -void Node::setDirtiedFunc(DirtiedCallback *dirtiedFunc) { +void Node::setDirtiedFunc(DirtiedCallback* dirtiedFunc) { m_dirtiedFunc.reset(dirtiedFunc); YGNodeSetDirtiedFunc(m_node, &globalDirtiedFunc); diff --git a/javascript/sources/Node.hh b/javascript/sources/Node.hh index 225b1727..d416f8e0 100644 --- a/javascript/sources/Node.hh +++ b/javascript/sources/Node.hh @@ -20,7 +20,8 @@ class MeasureCallback { public: virtual ~MeasureCallback() {} - virtual Size measure(float width, + virtual Size measure( + float width, int widthMode, float height, int heightMode) = 0; @@ -29,8 +30,7 @@ public: class MeasureCallbackWrapper : public emscripten::wrapper { public: EMSCRIPTEN_WRAPPER(MeasureCallbackWrapper); - Size measure(float width, int widthMode, float height, int heightMode) - { + Size measure(float width, int widthMode, float height, int heightMode) { return call("measure", width, widthMode, height, heightMode); } }; @@ -44,10 +44,7 @@ public: class DirtiedCallbackWrapper : public emscripten::wrapper { public: EMSCRIPTEN_WRAPPER(DirtiedCallbackWrapper); - void dirtied() - { - return call("dirtied"); - } + void dirtied() { return call("dirtied"); } }; class Node { @@ -180,7 +177,7 @@ public: // Tree hierarchy inspectors Node* getChild(unsigned index); public: // Measure func mutators - void setMeasureFunc(MeasureCallback *measureFunc); + void setMeasureFunc(MeasureCallback* measureFunc); void unsetMeasureFunc(void); public: // Measure func inspectors @@ -191,7 +188,7 @@ public: // Measure func inspectors int heightMode) const; public: // Dirtied func mutators - void setDirtiedFunc(DirtiedCallback *dirtiedFunc); + void setDirtiedFunc(DirtiedCallback* dirtiedFunc); void unsetDirtiedFunc(void); public: // Dirtied func inspectors diff --git a/javascript/sources/Value.hh b/javascript/sources/Value.hh index 38267dea..2a37d0e9 100644 --- a/javascript/sources/Value.hh +++ b/javascript/sources/Value.hh @@ -19,5 +19,5 @@ struct Value { Value(void) : unit(YGUnitUndefined), value(0.0) {} - Value(int unit, double value) : unit(unit), value(value) {} + Value(int unit, double value) : unit(unit), value(value) {} }; diff --git a/javascript/sources/embind.cc b/javascript/sources/embind.cc index 32ee65ad..96d6b018 100644 --- a/javascript/sources/embind.cc +++ b/javascript/sources/embind.cc @@ -18,171 +18,170 @@ using namespace emscripten; EMSCRIPTEN_BINDINGS(YOGA_LAYOUT) { class_("MeasureCallback") - .function("measure", &MeasureCallback::measure, pure_virtual()) - .allow_subclass("MeasureCallbackWrapper") - ; + .function("measure", &MeasureCallback::measure, pure_virtual()) + .allow_subclass("MeasureCallbackWrapper"); class_("DirtiedCallback") - .function("dirtied", &DirtiedCallback::dirtied, pure_virtual()) - .allow_subclass("DirtiedCallbackWrapper") - ; + .function("dirtied", &DirtiedCallback::dirtied, pure_virtual()) + .allow_subclass("DirtiedCallbackWrapper"); class_("Config") - .constructor<>(&Config::create, allow_raw_pointers()) - .class_function<>("create", &Config::create, allow_raw_pointers()) - .class_function<>("destroy", &Config::destroy, allow_raw_pointers()) - .function("setExperimentalFeatureEnabled", &Config::setExperimentalFeatureEnabled) - .function("setPointScaleFactor", &Config::setPointScaleFactor) - .function("isExperimentalFeatureEnabled", &Config::isExperimentalFeatureEnabled) - ; + .constructor<>(&Config::create, allow_raw_pointers()) + .class_function<>("create", &Config::create, allow_raw_pointers()) + .class_function<>("destroy", &Config::destroy, allow_raw_pointers()) + .function( + "setExperimentalFeatureEnabled", + &Config::setExperimentalFeatureEnabled) + .function("setPointScaleFactor", &Config::setPointScaleFactor) + .function( + "isExperimentalFeatureEnabled", + &Config::isExperimentalFeatureEnabled); value_object("Layout") - .field("left", &Layout::left) - .field("right", &Layout::right) - .field("top", &Layout::top) - .field("bottom", &Layout::bottom) - .field("width", &Layout::width) - .field("height", &Layout::height) - ; + .field("left", &Layout::left) + .field("right", &Layout::right) + .field("top", &Layout::top) + .field("bottom", &Layout::bottom) + .field("width", &Layout::width) + .field("height", &Layout::height); value_object("Size") - .field("width", &Size::width) - .field("height", &Size::height) - ; + .field("width", &Size::width) + .field("height", &Size::height); value_object("Value") - .field("value", &Value::value) - .field("unit", &Value::unit) - ; + .field("value", &Value::value) + .field("unit", &Value::unit); class_("Node") - .constructor<>(&Node::createDefault, allow_raw_pointers()) + .constructor<>(&Node::createDefault, allow_raw_pointers()) - .class_function<>("createDefault", &Node::createDefault, allow_raw_pointers()) - .class_function<>("createWithConfig", &Node::createWithConfig, allow_raw_pointers()) - .class_function<>("destroy", &Node::destroy, allow_raw_pointers()) - .function("reset", &Node::reset) + .class_function<>( + "createDefault", &Node::createDefault, allow_raw_pointers()) + .class_function<>( + "createWithConfig", &Node::createWithConfig, allow_raw_pointers()) + .class_function<>("destroy", &Node::destroy, allow_raw_pointers()) + .function("reset", &Node::reset) - .function("copyStyle", &Node::copyStyle) + .function("copyStyle", &Node::copyStyle) - .function("setPositionType", &Node::setPositionType) - .function("setPosition", &Node::setPosition) - .function("setPositionPercent", &Node::setPositionPercent) + .function("setPositionType", &Node::setPositionType) + .function("setPosition", &Node::setPosition) + .function("setPositionPercent", &Node::setPositionPercent) - .function("setAlignContent", &Node::setAlignContent) - .function("setAlignItems", &Node::setAlignItems) - .function("setAlignSelf", &Node::setAlignSelf) - .function("setFlexDirection", &Node::setFlexDirection) - .function("setFlexWrap", &Node::setFlexWrap) - .function("setJustifyContent", &Node::setJustifyContent) + .function("setAlignContent", &Node::setAlignContent) + .function("setAlignItems", &Node::setAlignItems) + .function("setAlignSelf", &Node::setAlignSelf) + .function("setFlexDirection", &Node::setFlexDirection) + .function("setFlexWrap", &Node::setFlexWrap) + .function("setJustifyContent", &Node::setJustifyContent) - .function("setMargin", &Node::setMargin) - .function("setMarginPercent", &Node::setMarginPercent) - .function("setMarginAuto", &Node::setMarginAuto) + .function("setMargin", &Node::setMargin) + .function("setMarginPercent", &Node::setMarginPercent) + .function("setMarginAuto", &Node::setMarginAuto) - .function("setOverflow", &Node::setOverflow) - .function("setDisplay", &Node::setDisplay) + .function("setOverflow", &Node::setOverflow) + .function("setDisplay", &Node::setDisplay) - .function("setFlex", &Node::setFlex) - .function("setFlexBasis", &Node::setFlexBasis) - .function("setFlexBasisPercent", &Node::setFlexBasisPercent) - .function("setFlexGrow", &Node::setFlexGrow) - .function("setFlexShrink", &Node::setFlexShrink) + .function("setFlex", &Node::setFlex) + .function("setFlexBasis", &Node::setFlexBasis) + .function("setFlexBasisPercent", &Node::setFlexBasisPercent) + .function("setFlexGrow", &Node::setFlexGrow) + .function("setFlexShrink", &Node::setFlexShrink) - .function("setWidth", &Node::setWidth) - .function("setWidthPercent", &Node::setWidthPercent) - .function("setWidthAuto", &Node::setWidthAuto) - .function("setHeight", &Node::setHeight) - .function("setHeightPercent", &Node::setHeightPercent) - .function("setHeightAuto", &Node::setHeightAuto) + .function("setWidth", &Node::setWidth) + .function("setWidthPercent", &Node::setWidthPercent) + .function("setWidthAuto", &Node::setWidthAuto) + .function("setHeight", &Node::setHeight) + .function("setHeightPercent", &Node::setHeightPercent) + .function("setHeightAuto", &Node::setHeightAuto) - .function("setMinWidth", &Node::setMinWidth) - .function("setMinWidthPercent", &Node::setMinWidthPercent) - .function("setMinHeight", &Node::setMinHeight) - .function("setMinHeightPercent", &Node::setMinHeightPercent) + .function("setMinWidth", &Node::setMinWidth) + .function("setMinWidthPercent", &Node::setMinWidthPercent) + .function("setMinHeight", &Node::setMinHeight) + .function("setMinHeightPercent", &Node::setMinHeightPercent) - .function("setMaxWidth", &Node::setMaxWidth) - .function("setMaxWidthPercent", &Node::setMaxWidthPercent) - .function("setMaxHeight", &Node::setMaxHeight) - .function("setMaxHeightPercent", &Node::setMaxHeightPercent) + .function("setMaxWidth", &Node::setMaxWidth) + .function("setMaxWidthPercent", &Node::setMaxWidthPercent) + .function("setMaxHeight", &Node::setMaxHeight) + .function("setMaxHeightPercent", &Node::setMaxHeightPercent) - .function("setAspectRatio", &Node::setAspectRatio) + .function("setAspectRatio", &Node::setAspectRatio) - .function("setBorder", &Node::setBorder) + .function("setBorder", &Node::setBorder) - .function("setPadding", &Node::setPadding) - .function("setPaddingPercent", &Node::setPaddingPercent) - .function("setGap", &Node::setGap) + .function("setPadding", &Node::setPadding) + .function("setPaddingPercent", &Node::setPaddingPercent) + .function("setGap", &Node::setGap) - .function("getPositionType", &Node::getPositionType) - .function("getPosition", &Node::getPosition) + .function("getPositionType", &Node::getPositionType) + .function("getPosition", &Node::getPosition) - .function("getAlignContent", &Node::getAlignContent) - .function("getAlignItems", &Node::getAlignItems) - .function("getAlignSelf", &Node::getAlignSelf) - .function("getFlexDirection", &Node::getFlexDirection) - .function("getFlexWrap", &Node::getFlexWrap) - .function("getJustifyContent", &Node::getJustifyContent) + .function("getAlignContent", &Node::getAlignContent) + .function("getAlignItems", &Node::getAlignItems) + .function("getAlignSelf", &Node::getAlignSelf) + .function("getFlexDirection", &Node::getFlexDirection) + .function("getFlexWrap", &Node::getFlexWrap) + .function("getJustifyContent", &Node::getJustifyContent) - .function("getMargin", &Node::getMargin) + .function("getMargin", &Node::getMargin) - .function("getFlexBasis", &Node::getFlexBasis) - .function("getFlexGrow", &Node::getFlexGrow) - .function("getFlexShrink", &Node::getFlexShrink) + .function("getFlexBasis", &Node::getFlexBasis) + .function("getFlexGrow", &Node::getFlexGrow) + .function("getFlexShrink", &Node::getFlexShrink) - .function("getWidth", &Node::getWidth) - .function("getHeight", &Node::getHeight) + .function("getWidth", &Node::getWidth) + .function("getHeight", &Node::getHeight) - .function("getMinWidth", &Node::getMinWidth) - .function("getMinHeight", &Node::getMinHeight) + .function("getMinWidth", &Node::getMinWidth) + .function("getMinHeight", &Node::getMinHeight) - .function("getMaxWidth", &Node::getMaxWidth) - .function("getMaxHeight", &Node::getMaxHeight) + .function("getMaxWidth", &Node::getMaxWidth) + .function("getMaxHeight", &Node::getMaxHeight) - .function("getAspectRatio", &Node::getAspectRatio) + .function("getAspectRatio", &Node::getAspectRatio) - .function("getBorder", &Node::getBorder) + .function("getBorder", &Node::getBorder) - .function("getOverflow", &Node::getOverflow) - .function("getDisplay", &Node::getDisplay) + .function("getOverflow", &Node::getOverflow) + .function("getDisplay", &Node::getDisplay) - .function("getPadding", &Node::getPadding) - .function("getGap", &Node::getGap) + .function("getPadding", &Node::getPadding) + .function("getGap", &Node::getGap) - .function("insertChild", &Node::insertChild, allow_raw_pointers()) - .function("removeChild", &Node::removeChild, allow_raw_pointers()) + .function("insertChild", &Node::insertChild, allow_raw_pointers()) + .function("removeChild", &Node::removeChild, allow_raw_pointers()) - .function("getChildCount", &Node::getChildCount) + .function("getChildCount", &Node::getChildCount) - .function("getParent", &Node::getParent, allow_raw_pointers()) - .function("getChild", &Node::getChild, allow_raw_pointers()) + .function("getParent", &Node::getParent, allow_raw_pointers()) + .function("getChild", &Node::getChild, allow_raw_pointers()) - .function("isReferenceBaseline", &Node::isReferenceBaseline) - .function("setIsReferenceBaseline", &Node::setIsReferenceBaseline) + .function("isReferenceBaseline", &Node::isReferenceBaseline) + .function("setIsReferenceBaseline", &Node::setIsReferenceBaseline) - .function("setMeasureFunc", &Node::setMeasureFunc, allow_raw_pointers()) - .function("unsetMeasureFunc", &Node::unsetMeasureFunc) + .function("setMeasureFunc", &Node::setMeasureFunc, allow_raw_pointers()) + .function("unsetMeasureFunc", &Node::unsetMeasureFunc) - .function("setDirtiedFunc", &Node::setDirtiedFunc, allow_raw_pointers()) - .function("unsetDirtiedFunc", &Node::unsetDirtiedFunc) + .function("setDirtiedFunc", &Node::setDirtiedFunc, allow_raw_pointers()) + .function("unsetDirtiedFunc", &Node::unsetDirtiedFunc) - .function("markDirty", &Node::markDirty) - .function("isDirty", &Node::isDirty) + .function("markDirty", &Node::markDirty) + .function("isDirty", &Node::isDirty) - .function("calculateLayout", &Node::calculateLayout) + .function("calculateLayout", &Node::calculateLayout) - .function("getComputedLeft", &Node::getComputedLeft) - .function("getComputedRight", &Node::getComputedRight) + .function("getComputedLeft", &Node::getComputedLeft) + .function("getComputedRight", &Node::getComputedRight) - .function("getComputedTop", &Node::getComputedTop) - .function("getComputedBottom", &Node::getComputedBottom) + .function("getComputedTop", &Node::getComputedTop) + .function("getComputedBottom", &Node::getComputedBottom) - .function("getComputedWidth", &Node::getComputedWidth) - .function("getComputedHeight", &Node::getComputedHeight) + .function("getComputedWidth", &Node::getComputedWidth) + .function("getComputedHeight", &Node::getComputedHeight) - .function("getComputedLayout", &Node::getComputedLayout) + .function("getComputedLayout", &Node::getComputedLayout) - .function("getComputedMargin", &Node::getComputedMargin) - .function("getComputedBorder", &Node::getComputedBorder) - .function("getComputedPadding", &Node::getComputedPadding) - ; + .function("getComputedMargin", &Node::getComputedMargin) + .function("getComputedBorder", &Node::getComputedBorder) + .function("getComputedPadding", &Node::getComputedPadding); }