-
Notifications
You must be signed in to change notification settings - Fork 182
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
Bidi Data Adapter #1784
Bidi Data Adapter #1784
Conversation
components/properties/src/bc.rs
Outdated
use icu_codepointtrie::CodePointTrie; | ||
|
||
pub struct BidiClassAdaptor { | ||
code_point_trie: CodePointTrie; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
code_point_trie: CodePointTrie; | |
code_point_trie: CodePointTrie, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
components/properties/src/bc.rs
Outdated
use icu::properties::{maps, BidiClass}; | ||
use icu_codepointtrie::CodePointTrie; | ||
|
||
pub struct BidiClassAdaptor { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Adapter
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
components/properties/src/bc.rs
Outdated
maps::get_bidi_class(&provider) | ||
.expect("The data should be valid"); | ||
let data_struct = payload.get(); | ||
BidiClassAdaptor{ data_struct.code_point_trie } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BidiClassAdaptor{ data_struct.code_point_trie } | |
BidiClassAdaptor{ code_point_trie: data_struct.code_point_trie } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For now, I added a reference to the provider. However, I would like to have a way to save a reference to the code_point_trie instead. Shall I pass a code_point_trie?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have added it.
components/properties/Cargo.toml
Outdated
@@ -38,6 +38,7 @@ icu_provider = { version = "0.5", path = "../../provider/core", features = ["mac | |||
icu_uniset = { version = "0.4.1", path = "../../utils/uniset"} | |||
serde = { version = "1.0", default-features = false, features = ["derive", "alloc"], optional = true } | |||
zerovec = { version = "0.6", path = "../../utils/zerovec", features = ["derive"] } | |||
unicode-bidi = "0.3.7" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Issue: This should be an optional dependency. Enabling this dependency should enable the code that uses it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done!
components/properties/src/bc.rs
Outdated
@@ -0,0 +1,71 @@ | |||
// This file is part of ICU4X. For terms of use, please see the file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit
: please, name this file src/bidi.rs
- bc
becomes very cryptic for readers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
components/properties/src/bc.rs
Outdated
// called LICENSE at the top level of the ICU4X source tree | ||
// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ). | ||
|
||
use crate::BidiDataSource; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question
: where is BidiDataSource
defined? Why do you need a trait?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it comes from the unicode-bidi
crate. The import needs to be fixed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, it comes from unicode-bidi
and I have fixed the import.
@zbraniecki , we need to implement to plugin the data from ICU4X to unicode-bidi.
components/properties/src/bidi.rs
Outdated
BidiClass::LeftToRightIsolate => DataSourceBidiClass::LRI, | ||
BidiClass::RightToLeftIsolate => DataSourceBidiClass::RLI, | ||
BidiClass::PopDirectionalIsolate => DataSourceBidiClass::PDI, | ||
_ => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what shall we do here? unfortunately, BidiClass is not an enum?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should return the neutral/undefined/default value.
Running this code is rare, but it can happen if old code runs with new data.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I have returned Other_Neutral
components/properties/src/lib.rs
Outdated
@@ -92,3 +93,5 @@ pub use props::{ | |||
BidiClass, CanonicalCombiningClass, EastAsianWidth, EnumeratedProperty, GeneralCategory, | |||
GeneralCategoryGroup, GraphemeClusterBreak, LineBreak, Script, SentenceBreak, WordBreak, | |||
}; | |||
|
|||
pub use bidi::BidiClassAdapter; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Don't hoist this to the top. Leave it exported under the bidi module.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did not get this, could you illustrate more?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should clients write
use icu_properties::BidiClassAdapter;
or
use icu_properties::bidi::BidiClassAdapter;
I think we should lean toward putting this into a child namespace rather than the top level, but I can be convinced otherwise.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think child module makes sense
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
520bda6
to
f636b12
Compare
Notice: the branch changed across the force-push!
~ Your Friendly Jira-GitHub PR Checker Bot |
components/properties/Cargo.toml
Outdated
@@ -52,3 +54,4 @@ std = ["icu_provider/std"] | |||
default = [] | |||
serde = ["dep:serde", "zerovec/serde", "icu_uniset/serde", "icu_codepointtrie/serde"] | |||
datagen = ["serde", "zerovec/serde_serialize", "icu_uniset/serde_serialize", "icu_codepointtrie/serde_serialize"] | |||
unicode-bidi = [ "dep:unicode-bidi" ] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: name the feature just "bidi"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
components/properties/Cargo.toml
Outdated
icu_uniset = { version = "0.4.1", path = "../../utils/uniset"} | ||
serde = { version = "1.0", default-features = false, features = ["derive", "alloc"], optional = true } | ||
zerovec = { version = "0.6", path = "../../utils/zerovec", features = ["derive"] } | ||
unicode-bidi = { git = "https://github.com/servo/unicode-bidi", optional = true , deafault-features = false } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i've made servo/unicode-bidi#78 to get this published, since we have a working PR now and are close to landing it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I am waiting to merge it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
Co-authored-by: Shane F. Carr <[email protected]>
Co-authored-by: Manish Goregaokar <[email protected]>
components/properties/Cargo.toml
Outdated
|
||
[dev-dependencies] | ||
icu = { path = "../icu", default-features = false } | ||
icu_testdata = { version = "0.5", path = "../../provider/testdata" } | ||
icu_provider_fs = {version = "0.5.0", path = "../../provider/fs" } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: I do not think you are using this dependency, so you should remove it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
Closes: #1784