Repository navigation
Bidi Data Adapter - #1784
Bidi Data Adapter#1784
Conversation
| use icu_codepointtrie::CodePointTrie; | ||
|
|
||
| pub struct BidiClassAdaptor { | ||
| code_point_trie: CodePointTrie; |
There was a problem hiding this comment.
| code_point_trie: CodePointTrie; | |
| code_point_trie: CodePointTrie, |
| use icu::properties::{maps, BidiClass}; | ||
| use icu_codepointtrie::CodePointTrie; | ||
|
|
||
| pub struct BidiClassAdaptor { |
| 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.
| BidiClassAdaptor{ data_struct.code_point_trie } | |
| BidiClassAdaptor{ code_point_trie: data_struct.code_point_trie } |
There was a problem hiding this comment.
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?
| 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.
Issue: This should be an optional dependency. Enabling this dependency should enable the code that uses it.
| @@ -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.
nit: please, name this file src/bidi.rs - bc becomes very cryptic for readers.
| // 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.
question: where is BidiDataSource defined? Why do you need a trait?
There was a problem hiding this comment.
I think it comes from the unicode-bidi crate. The import needs to be fixed.
There was a problem hiding this comment.
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.
| BidiClass::LeftToRightIsolate => DataSourceBidiClass::LRI, | ||
| BidiClass::RightToLeftIsolate => DataSourceBidiClass::RLI, | ||
| BidiClass::PopDirectionalIsolate => DataSourceBidiClass::PDI, | ||
| _ => { |
There was a problem hiding this comment.
what shall we do here? unfortunately, BidiClass is not an enum?
There was a problem hiding this comment.
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.
Okay, I have returned Other_Neutral
| GeneralCategoryGroup, GraphemeClusterBreak, LineBreak, Script, SentenceBreak, WordBreak, | ||
| }; | ||
|
|
||
| pub use bidi::BidiClassAdapter; |
There was a problem hiding this comment.
Nit: Don't hoist this to the top. Leave it exported under the bidi module.
There was a problem hiding this comment.
I did not get this, could you illustrate more?
There was a problem hiding this comment.
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.
I think child module makes sense
520bda6 to
f636b12
Compare
|
Notice: the branch changed across the force-push!
~ Your Friendly Jira-GitHub PR Checker Bot |
| 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" ] No newline at end of file |
There was a problem hiding this comment.
Suggestion: name the feature just "bidi"
| 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.
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.
Okay, I am waiting to merge it.
Co-authored-by: Shane F. Carr <[email protected]>
Co-authored-by: Manish Goregaokar <[email protected]>
| [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.
Nit: I do not think you are using this dependency, so you should remove it
Closes: #1784