Skip to content

Commit

Permalink
Adds support for basic message formatting. (#57)
Browse files Browse the repository at this point in the history
ICU compatible MessageFormat for rust is here.  Implemented functions
are from the header `umsg.h`:

- Constructor/destructor: `umsg_open`, `umsg_close` through standard
  Rust mechanisms.
- Formatting: `umsg_format` and `umsg_vformat` through `message_format!`
  macro, since the distinction does not matter in rust.
- Documentation and tests.

Slated for v0.1.1 as this is a backward-compatible API.

Fixes: 56
  • Loading branch information
filmil committed Mar 25, 2020
1 parent cc8edf9 commit f9defdc
Show file tree
Hide file tree
Showing 16 changed files with 552 additions and 37 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ members = [
"rust_icu_uloc",
"rust_icu_ustring",
"rust_icu_utext",
"rust_icu_umsg",
]

4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ publish:
# A helper to up-rev the cargo crate versions.
# NOTE: The cargo crate version number is completely independent of the Docker
# build environment version number.
UPREV_OLD_VERSION ?= 0.1.0
UPREV_NEW_VERSION ?= 0.1.1
UPREV_OLD_VERSION ?= 0.1.1
UPREV_NEW_VERSION ?= 0.1.2
define uprev
( \
cd $(1) && \
Expand Down
4 changes: 2 additions & 2 deletions rust_icu_common/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
edition = "2018"
name = "rust_icu_common"
version = "0.1.0"
version = "0.1.1"
authors = ["Google Inc."]
license = "Apache-2.0"
readme = "README.md"
Expand All @@ -20,7 +20,7 @@ keywords = ["icu", "unicode", "i18n", "l10n"]
anyhow = "1.0.25"
thiserror = "1.0.9"

rust_icu_sys = { path = "../rust_icu_sys", version = "0.1.0", default-features = false}
rust_icu_sys = { path = "../rust_icu_sys", version = "0.1.1", default-features = false}

# See the feature description in ../rust_icu_sys/Cargo.toml for details.
[features]
Expand Down
2 changes: 1 addition & 1 deletion rust_icu_sys/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "rust_icu_sys"
version = "0.1.0"
version = "0.1.1"
authors = ["Google Inc."]
license = "Apache-2.0"
readme = "README.md"
Expand Down
6 changes: 4 additions & 2 deletions rust_icu_sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,11 +214,13 @@ fn run_bindgen(header_file: &str, out_dir_path: &Path) -> Result<()> {
"UDateFormat.*",
"UEnumeration.*",
"UErrorCode",
"UMessageFormat",
"UParseError",
"UText.*",
]);

let whitelist_functions_regexes = commaify(&vec![
"u_.*", "ucal_.*", "udata_*", "udat_.*", "uenum_.*", "uloc_.*", "utext_.*",
"u_.*", "ucal_.*", "udata_*", "udat_.*", "uenum_.*", "uloc_.*", "utext_.*", "umsg_.*",
]);

let opaque_types_regexes = commaify(&vec![]);
Expand Down Expand Up @@ -376,7 +378,7 @@ fn icu_config_autodetect() -> Result<()> {
// relationship between the respective headers.
// Any of these will fail if the required binaries are not present in $PATH.
let bindgen_source_modules: Vec<&str> = vec![
"ucal", "udat", "udata", "uenum", "ustring", "utext", "uclean",
"ucal", "udat", "udata", "uenum", "ustring", "utext", "uclean", "umsg",
];
let header_file =
generate_wrapper_header(&out_dir_path, &bindgen_source_modules, &include_dir_path);
Expand Down
10 changes: 5 additions & 5 deletions rust_icu_ucal/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ license = "Apache-2.0"
name = "rust_icu_ucal"
readme = "README.md"
repository = "https://github.com/google/rust_icu"
version = "0.1.0"
version = "0.1.1"

description = """
Native bindings to the ICU4C library from Unicode.
Expand All @@ -18,10 +18,10 @@ keywords = ["icu", "unicode", "i18n", "l10n"]
[dependencies]
log = "0.4.6"
paste = "0.1.5"
rust_icu_common = { path = "../rust_icu_common", version = "0.1.0", default-features = false }
rust_icu_sys = { path = "../rust_icu_sys", version = "0.1.0", default-features = false }
rust_icu_uenum = { path = "../rust_icu_uenum", version = "0.1.0", default-features = false }
rust_icu_ustring = { path = "../rust_icu_ustring", version = "0.1.0", default-features = false }
rust_icu_common = { path = "../rust_icu_common", version = "0.1.1", default-features = false }
rust_icu_sys = { path = "../rust_icu_sys", version = "0.1.1", default-features = false }
rust_icu_uenum = { path = "../rust_icu_uenum", version = "0.1.1", default-features = false }
rust_icu_ustring = { path = "../rust_icu_ustring", version = "0.1.1", default-features = false }

[dev-dependencies]
regex = "1"
Expand Down
14 changes: 7 additions & 7 deletions rust_icu_udat/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ license = "Apache-2.0"
name = "rust_icu_udat"
readme = "README.md"
repository = "https://github.com/google/rust_icu"
version = "0.1.0"
version = "0.1.1"

description = """
Native bindings to the ICU4C library from Unicode.
Expand All @@ -18,12 +18,12 @@ keywords = ["icu", "unicode", "i18n", "l10n"]
[dependencies]
log = "0.4.6"
paste = "0.1.5"
rust_icu_common = { path = "../rust_icu_common", version = "0.1.0", default-features = false }
rust_icu_sys = { path = "../rust_icu_sys", version = "0.1.0", default-features = false }
rust_icu_ucal = { path = "../rust_icu_ucal", version = "0.1.0", default-features = false }
rust_icu_uenum = { path = "../rust_icu_uenum", version = "0.1.0", default-features = false }
rust_icu_uloc = { path = "../rust_icu_uloc", version = "0.1.0", default-features = false }
rust_icu_ustring = { path = "../rust_icu_ustring", version = "0.1.0", default-features = false }
rust_icu_common = { path = "../rust_icu_common", version = "0.1.1", default-features = false }
rust_icu_sys = { path = "../rust_icu_sys", version = "0.1.1", default-features = false }
rust_icu_ucal = { path = "../rust_icu_ucal", version = "0.1.1", default-features = false }
rust_icu_uenum = { path = "../rust_icu_uenum", version = "0.1.1", default-features = false }
rust_icu_uloc = { path = "../rust_icu_uloc", version = "0.1.1", default-features = false }
rust_icu_ustring = { path = "../rust_icu_ustring", version = "0.1.1", default-features = false }

# See the feature description in ../rust_icu_sys/Cargo.toml for details.
[features]
Expand Down
6 changes: 3 additions & 3 deletions rust_icu_udata/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ license = "Apache-2.0"
name = "rust_icu_udata"
readme = "README.md"
repository = "https://github.com/google/rust_icu"
version = "0.1.0"
version = "0.1.1"

description = """
Native bindings to the ICU4C library from Unicode.
Expand All @@ -18,8 +18,8 @@ keywords = ["icu", "unicode", "i18n", "l10n"]
[dependencies]
log = "0.4.6"
paste = "0.1.5"
rust_icu_common = { path = "../rust_icu_common", version = "0.1.0", default-features = false }
rust_icu_sys = { path = "../rust_icu_sys", version = "0.1.0", default-features = false }
rust_icu_common = { path = "../rust_icu_common", version = "0.1.1", default-features = false }
rust_icu_sys = { path = "../rust_icu_sys", version = "0.1.1", default-features = false }

# See the feature description in ../rust_icu_sys/Cargo.toml for details.
[features]
Expand Down
6 changes: 3 additions & 3 deletions rust_icu_uenum/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ license = "Apache-2.0"
name = "rust_icu_uenum"
readme = "README.md"
repository = "https://github.com/google/rust_icu"
version = "0.1.0"
version = "0.1.1"

description = """
Native bindings to the ICU4C library from Unicode.
Expand All @@ -17,8 +17,8 @@ keywords = ["icu", "unicode", "i18n", "l10n"]

[dependencies]
paste = "0.1.5"
rust_icu_sys = { path = "../rust_icu_sys", version = "0.1.0", default-features = false }
rust_icu_common = { path = "../rust_icu_common", version = "0.1.0", default-features = false }
rust_icu_sys = { path = "../rust_icu_sys", version = "0.1.1", default-features = false }
rust_icu_common = { path = "../rust_icu_common", version = "0.1.1", default-features = false }

# See the feature description in ../rust_icu_sys/Cargo.toml for details.
[features]
Expand Down
10 changes: 5 additions & 5 deletions rust_icu_uloc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ license = "Apache-2.0"
name = "rust_icu_uloc"
readme = "README.md"
repository = "https://github.com/google/rust_icu"
version = "0.1.0"
version = "0.1.1"
default-features = false
keywords = ["icu", "unicode", "i18n", "l10n"]

Expand All @@ -18,10 +18,10 @@ uloc.h
[dependencies]
log = "0.4.6"
paste = "0.1.5"
rust_icu_common = { path = "../rust_icu_common", version = "0.1.0", default-features = false }
rust_icu_sys = { path = "../rust_icu_sys", version = "0.1.0", default-features = false }
rust_icu_uenum = { path = "../rust_icu_uenum", version = "0.1.0", default-features = false }
rust_icu_ustring = { path = "../rust_icu_ustring", version = "0.1.0", default-features = false }
rust_icu_common = { path = "../rust_icu_common", version = "0.1.1", default-features = false }
rust_icu_sys = { path = "../rust_icu_sys", version = "0.1.1", default-features = false }
rust_icu_uenum = { path = "../rust_icu_uenum", version = "0.1.1", default-features = false }
rust_icu_ustring = { path = "../rust_icu_ustring", version = "0.1.1", default-features = false }

[dev-dependencies]
anyhow = "1.0.25"
Expand Down
39 changes: 39 additions & 0 deletions rust_icu_umsg/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
[package]
authors = ["Google Inc."]
edition = "2018"
license = "Apache-2.0"
name = "rust_icu_umsg"
readme = "README.md"
repository = "https://github.com/google/rust_icu"
version = "0.1.0"

description = """
Native bindings to the ICU4C library from Unicode.
umsg.h
"""

keywords = ["icu", "unicode", "i18n", "l10n"]

[dependencies]
anyhow = "1.0.25"
log = "0.4.6"
paste = "0.1.5"
rust_icu_common = { path = "../rust_icu_common", version = "0.1.0", default-features = false }
rust_icu_sys = { path = "../rust_icu_sys", version = "0.1.0", default-features = false }
rust_icu_uloc = { path = "../rust_icu_uloc", version = "0.1.0", default-features = false }
rust_icu_ustring = { path = "../rust_icu_ustring", version = "0.1.0", default-features = false }
thiserror = "1.0.9"

[dev-dependencies]
rust_icu_ucal = { path = "../rust_icu_ucal", version = "0.1.0", default-features = false }

# See the feature description in ../rust_icu_sys/Cargo.toml for details.
[features]
default = ["bindgen", "renaming", "icu_config"]

bindgen = ["rust_icu_sys/bindgen", "rust_icu_common/bindgen"]
renaming = ["rust_icu_sys/renaming", "rust_icu_common/renaming"]
icu_config = ["rust_icu_sys/icu_config", "rust_icu_common/icu_config"]
icu_version_in_env = ["rust_icu_sys/icu_version_in_env", "rust_icu_common/icu_version_in_env"]

1 change: 1 addition & 0 deletions rust_icu_umsg/README.md

0 comments on commit f9defdc

Please sign in to comment.