Skip to content

Allow parsing lists of compound data types#49188

Closed
NickGerleman wants to merge 3 commits into
facebook:mainfrom
NickGerleman:export-D69142157
Closed

Allow parsing lists of compound data types#49188
NickGerleman wants to merge 3 commits into
facebook:mainfrom
NickGerleman:export-D69142157

Conversation

@NickGerleman
Copy link
Copy Markdown
Contributor

Summary:
This allows creating lists of a compound data type, storing each element as a variant of the possible types, instead of as the specified type.

Changelog: [Internal]

Reviewed By: lenaic

Differential Revision: D69142157

Summary:
Next up for transforms, and for some future cases, it is convenient to be able to export a single marker type like `CSSTransform`, that can expand to a variant of multiple possible types of different shape (e.g. `CSSMatrix3D` vs `CSSScale`).

It is also best (for code size) to only have a single representation of compound types (e.g. `<CSSLength, CSSPercentage>` generates a separate copy of code compared to `<CSSPercentage, CSSLength>`).

This diff introduces `CSSCompoundDataTypes` which allows composing types, which are then flattened out to discrete types during parsing. For simplicity, `CSSCompoundDataType` cannot currently be nested inside of other `CSSCompoundDataType`, though this could be added in the future.

```
/**
 * Marker for the <length-percentage> data type
 * https://drafts.csswg.org/css-values/#mixed-percentages
 */
using CSSLengthPercentage = CSSCompoundDataType<CSSLength, CSSPercentage>;
```

Changelog: [Internal]

Reviewed By: lenaic

Differential Revision: D69089416
Summary:
`tolower` is not `constexpr`. Share some quick utilities for char to lowercase, and case insensitive comparision that does not create new string.

Changelog: [Internal]

Reviewed By: lenaic

Differential Revision: D69134770
Summary:
This allows creating lists of a compound data type, storing each element as a variant of the possible types, instead of as the specified type.

Changelog: [Internal]

Reviewed By: lenaic

Differential Revision: D69142157
@facebook-github-bot facebook-github-bot added CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. p: Facebook Partner: Facebook Partner labels Feb 5, 2025
@facebook-github-bot
Copy link
Copy Markdown
Contributor

This pull request was exported from Phabricator. Differential Revision: D69142157

@facebook-github-bot
Copy link
Copy Markdown
Contributor

This pull request has been merged in 1def9fd.

@facebook-github-bot facebook-github-bot added the Merged This PR has been merged. label Feb 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported Merged This PR has been merged. p: Facebook Partner: Facebook Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants