-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
LibUnicode+LibWeb: Rework bidirectional_class() API a bit #25458
Conversation
Changes the generated UnicodeData.h from enum class BidirectionalClass : BidirectionalClassUnderlyingType { AL, AN, B, ... }; to enum class BidirectionalClass : BidirectionalClassUnderlyingType { AL, AN, B, ... Arabic_Letter = AL, Arabic_Number = AN, Boundary_Neutral = BN, ... };
473063c
to
499c074
Compare
@trflynn89 Do you want to look at LibUnicode changes over here, or should I just merge? |
Code LGTM. This does break the ability to build with UCD downloads disabled - I generally tried to keep that config building/non-crashing, but if we want to step away from that, that's fine. (I don't know if the build even currently works with UCD downloads disabled, it was just something I tested every couple months or so, or if someone using the option pointed out that it broke). |
I didn't test it, but I intended that that keeps working. There's still a weak symbol of the generated function. Is there more I have to take care of? (I suppose I could actually try building with it disabled...) |
...oh, probably because I'm using the generated enum values unconditionally. I'll tweak that, thanks! |
Before this commit, GenerateUnicodeData generated a `BidirectionalClass` enum directly from UnicodeData.txt. Now, GenerateUnicodeData instead generates `BidirectionalClassInternal` and CharacterTypes.h has an explicit enum `BidiClass` with nicer names -- no underscores, but also names more similar to ICUs names. (Since CharacterTypes.h is included in some of LibUnicode's generators, it can't refer to generated `BidirectionalClassInternal`, so we instead have a big manual mapping switch in UnicodeData.cpp.) `bidirectional_class()` used to return an `Optional<BidirectionalClass>` for when unicode data was disabled. Now we return `BidiClass` and just return `BidiClass::LeftToRight` instead of making every client do this. It also updates LibWeb's Element.cpp to this new system. Also remove now-unused `bidirectional_class_from_string()`. This kind of cherry-picks the 4th commit of LadybirdBrowser/ladybird#239 (aa3a30870b58c47cb37bce1418d7e6bee7af71d9): The CharacterTypes.h, Element.cpp and TestUnicodeCharacterTypes.cpp changes are by trflynn. Co-authored-by: Tim Flynn <trflynn89@serenityos.org>
499c074
to
b28a411
Compare
Done! (I did try changing |
Before this commit, GenerateUnicodeData generated a
BidirectionalClass
enum directly from UnicodeData.txt.Now, GenerateUnicodeData instead generates
BidirectionalClassInternal
and CharacterTypes.h has an explicit enum
BidiClass
with nicer names-- no underscores, but also names more similar to ICUs names.
(Since CharacterTypes.h is included in some of LibUnicode's generators,
it can't refer to generated
BidirectionalClassInternal
, so we insteadhave a big manual mapping switch in UnicodeData.cpp.)
bidirectional_class()
used to return anOptional<BidirectionalClass>
for when unicode data was disabled. Now we return
BidiClass
andjust return
BidiClass::LeftToRight
instead of making every clientdo this.
It also updates LibWeb's Element.cpp to this new system.
Also remove now-unused
bidirectional_class_from_string()
.This kind of cherry-picks the 4th commit of
LadybirdBrowser/ladybird#239 (aa3a30870b58c47cb37bce1418d7e6bee7af71d9):
The CharacterTypes.h, Element.cpp and TestUnicodeCharacterTypes.cpp changes are
by trflynn.
Co-authored-by: Tim Flynn trflynn89@serenityos.org