Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C++ Cleanup 4/N: Reorganize Log and YGNodePrint (#39197) #39220

Closed
wants to merge 4 commits into from

Commits on Aug 30, 2023

  1. C++ Cleanup 1/N: Reorganize YGStyle (facebook#39171)

    Summary:
    X-link: facebook/yoga#1349
    
    Pull Request resolved: facebook#39171
    
    ## This diff
    
    This diff adds a `style` directory for code related to storing and manipulating styles. `YGStyle`, which is not a public API, is renamed to `yoga::Style` and moved into this folder, alongside `CompactValue`. We will eventually add `ValuePool` alongside this for the next generation style representation.
    
    ## This stack
    
    The organization of the C++ internals of Yoga are in need of attention.
    1. Some of the C++ internals are namespaced, but others not.
    2. Some of the namespaces include `detail`, but are meant to be used outside of the translation unit (FB Clang Tidy rules warn on any usage of these)
    2. Most of the files are in a flat hierarchy, except for event tracing in its own folder
    3. Some files and functions begin with YG, others don’t
    4. Some functions are uppercase, others are not
    5. Almost all of the interesting logic is in Yoga.cpp, and the file is too large to reason about
    6. There are multiple grab bag files where folks put random functions they need in (Utils, BitUtils, Yoga-Internal.h)
    7. There is no clear indication from file structure or type naming what is private vs not
    8. Handles like `YGNodeRef` and `YGConfigRef` can be used to access internals just by importing headers
    
    This stack does some much needed spring cleaning:
    1. All non-public headers and C++ implementation details are in separate folders from the root level `yoga`. This will give us room to split up logic and add more files without too large a flat hierarchy
    3. All private C++ internals are under the `facebook::yoga` namespace. Details namespaces are only ever used within the same header, as they are intended
    4. Utils files are split
    5. Most C++ internals drop the YG prefix
    6. Most C++ internal function names are all lower camel case
    7. We start to split up Yoga.cpp
    8. Every header beginning with YG or at the top-level directory is public and C only, with the exception of Yoga-Internal.h which has non-public functions for bindings
    9. It is not possible to use private APIs without static casting handles to internal classes
    
    This will give us more leeway to continue splitting monolithic files, and consistent guidelines for style in new files as well.
    
    These changes should not be breaking to any project using only public Yoga headers. This includes every usage of Yoga in fbsource except for RN Fabric which is currently tied to internals. This refactor should make that boundary clearer.
    
    Changelog: [Internal]
    
    Differential Revision: D48847261
    
    fbshipit-source-id: 8878d9521945af6dc43bd8d2a5fdef87e04d66c9
    NickGerleman authored and facebook-github-bot committed Aug 30, 2023
    Configuration menu
    Copy the full SHA
    b768ae8 View commit details
    Browse the repository at this point in the history
  2. C++ Cleanup 2/N: Reorganize YGConfig (facebook#39169)

    Summary:
    Pull Request resolved: facebook#39169
    
    X-link: facebook/yoga#1348
    
    ## This diff
    
    This diff adds a top level `config` directory for code related to configuring Yoga and Yoga Nodes.
    
    The public API for config handles is `YGConfigRef`, which is forward declared to be a pointer to a struct named `YGConfig`. The existing `YGConfig` is split into `yoga::Config`, as the private C++ implementation, inheriting from `YGConfig`, a marker type represented as an empty struct. The public API continues to accept `YGConfigRef`, which continues to be `YGConfig *`, but it must be cast to its concrete internal representation at the API boundary before doing work on it.
    
    ## This stack
    
    The organization of the C++ internals of Yoga are in need of attention.
    1. Some of the C++ internals are namespaced, but others not.
    2. Some of the namespaces include `detail`, but are meant to be used outside of the translation unit (FB Clang Tidy rules warn on any usage of these)
    2. Most of the files are in a flat hierarchy, except for event tracing in its own folder
    3. Some files and functions begin with YG, others don’t
    4. Some functions are uppercase, others are not
    5. Almost all of the interesting logic is in Yoga.cpp, and the file is too large to reason about
    6. There are multiple grab bag files where folks put random functions they need in (Utils, BitUtils, Yoga-Internal.h)
    7. There is no clear indication from file structure or type naming what is private vs not
    8. Handles like `YGNodeRef` and `YGConfigRef` can be used to access internals just by importing headers
    
    This stack does some much needed spring cleaning:
    1. All non-public headers and C++ implementation details are in separate folders from the root level `yoga`. This will give us room to split up logic and add more files without too large a flat hierarchy
    3. All private C++ internals are under the `facebook::yoga` namespace. Details namespaces are only ever used within the same header, as they are intended
    4. Utils files are split
    5. Most C++ internals drop the YG prefix
    6. Most C++ internal function names are all lower camel case
    7. We start to split up Yoga.cpp
    8. Every header beginning with YG or at the top-level directory is public and C only, with the exception of Yoga-Internal.h which has non-public functions for bindings
    9. It is not possible to use private APIs without static casting handles to internal classes
    
    This will give us more leeway to continue splitting monolithic files, and consistent guidelines for style in new files as well.
    
    These changes should not be breaking to any project using only public Yoga headers. This includes every usage of Yoga in fbsource except for RN Fabric which is currently tied to internals. This refactor should make that boundary clearer.
    
    Changelog: [Internal]
    
    Differential Revision: D48847257
    
    fbshipit-source-id: 182cc5c30645d87ae46ff814d1abf294d319290c
    NickGerleman authored and facebook-github-bot committed Aug 30, 2023
    Configuration menu
    Copy the full SHA
    9ba3fcb View commit details
    Browse the repository at this point in the history
  3. C++ Cleanup 3/N: Reorganize YGNode (facebook#39170)

    Summary:
    X-link: facebook/yoga#1350
    
    Pull Request resolved: facebook#39170
    
    ## This diff
    
    This diff adds a top level `node` directory for code related to Yoga nodes and data structures on them (inc moving `YGLayout` to `LayoutResults`).
    
    The public API for config handles is `YGNodeRef`, which is forward declared to be a pointer to a struct named `YGNode`. The existing `YGNode` is split into `yoga::Node`, as the private C++ implementation, inheriting from `YGNode`, a marker type represented as an empty struct. The public API continues to accept `YGNodeRef`, which continues to be `YGNode *`, but it must be cast to its concrete internal representation at the API boundary before doing work on it.
    
    This change ends up needing to touch quite a bit, due to the amount of code that mixed and matched private and public APIs. Don't be scared though, because these changes are very mechanical, and Phabricator's line-count is 3x the actual amount due to mirrors and dirsyncs.
    
    ## This stack
    
    The organization of the C++ internals of Yoga are in need of attention.
    1. Some of the C++ internals are namespaced, but others not.
    2. Some of the namespaces include `detail`, but are meant to be used outside of the translation unit (FB Clang Tidy rules warn on any usage of these)
    2. Most of the files are in a flat hierarchy, except for event tracing in its own folder
    3. Some files and functions begin with YG, others don’t
    4. Some functions are uppercase, others are not
    5. Almost all of the interesting logic is in Yoga.cpp, and the file is too large to reason about
    6. There are multiple grab bag files where folks put random functions they need in (Utils, BitUtils, Yoga-Internal.h)
    7. There is no clear indication from file structure or type naming what is private vs not
    8. Handles like `YGNodeRef` and `YGConfigRef` can be used to access internals just by importing headers
    
    This stack does some much needed spring cleaning:
    1. All non-public headers and C++ implementation details are in separate folders from the root level `yoga`. This will give us room to split up logic and add more files without too large a flat hierarchy
    3. All private C++ internals are under the `facebook::yoga` namespace. Details namespaces are only ever used within the same header, as they are intended
    4. Utils files are split
    5. Most C++ internals drop the YG prefix
    6. Most C++ internal function names are all lower camel case
    7. We start to split up Yoga.cpp
    8. Every header beginning with YG or at the top-level directory is public and C only, with the exception of Yoga-Internal.h which has non-public functions for bindings
    9. It is not possible to use private APIs without static casting handles to internal classes
    
    This will give us more leeway to continue splitting monolithic files, and consistent guidelines for style in new files as well.
    
    These changes should not be breaking to any project using only public Yoga headers. This includes every usage of Yoga in fbsource except for RN Fabric which is currently tied to internals. This refactor should make that boundary clearer.
    
    Changelog: [Internal]
    
    Differential Revision: D48847258
    
    fbshipit-source-id: 5b6278482133dc53bc338c1f8682fd24bc67ada2
    NickGerleman authored and facebook-github-bot committed Aug 30, 2023
    Configuration menu
    Copy the full SHA
    359b448 View commit details
    Browse the repository at this point in the history
  4. C++ Cleanup 4/N: Reorganize Log and YGNodePrint (facebook#39197)

    Summary:
    X-link: facebook/yoga#1354
    
    Pull Request resolved: facebook#39197
    
    ## This diff
    
    Moves these files to a `yoga/debug` subdirectory and does some mild renaming, namespace adjustment, and removes Yoga internal log function from list of library exports.
    
    ## This stack
    
    The organization of the C++ internals of Yoga are in need of attention.
    1. Some of the C++ internals are namespaced, but others not.
    2. Some of the namespaces include `detail`, but are meant to be used outside of the translation unit (FB Clang Tidy rules warn on any usage of these)
    2. Most of the files are in a flat hierarchy, except for event tracing in its own folder
    3. Some files and functions begin with YG, others don’t
    4. Some functions are uppercase, others are not
    5. Almost all of the interesting logic is in Yoga.cpp, and the file is too large to reason about
    6. There are multiple grab bag files where folks put random functions they need in (Utils, BitUtils, Yoga-Internal.h)
    7. There is no clear indication from file structure or type naming what is private vs not
    8. Handles like `YGNodeRef` and `YGConfigRef` can be used to access internals just by importing headers
    
    This stack does some much needed spring cleaning:
    1. All non-public headers and C++ implementation details are in separate folders from the root level `yoga`. This will give us room to split up logic and add more files without too large a flat hierarchy
    3. All private C++ internals are under the `facebook::yoga` namespace. Details namespaces are only ever used within the same header, as they are intended
    4. Utils files are split
    5. Most C++ internals drop the YG prefix
    6. Most C++ internal function names are all lower camel case
    7. We start to split up Yoga.cpp
    8. Every header beginning with YG or at the top-level directory is public and C only, with the exception of Yoga-Internal.h which has non-public functions for bindings
    9. It is not possible to use private APIs without static casting handles to internal classes
    
    This will give us more leeway to continue splitting monolithic files, and consistent guidelines for style in new files as well.
    
    These changes should not be breaking to any project using only public Yoga headers. This includes every usage of Yoga in fbsource except for RN Fabric which is currently tied to internals. This refactor should make that boundary clearer.
    
    Reviewed By: shwanton
    
    Differential Revision: D48847259
    
    fbshipit-source-id: 34417c69c55ddca51a38ceecdf38a837b8bd3d6c
    NickGerleman authored and facebook-github-bot committed Aug 30, 2023
    Configuration menu
    Copy the full SHA
    35c213d View commit details
    Browse the repository at this point in the history