Skip to content

Commit

Permalink
Make FixedDecimal's round to increment methods experimental
Browse files Browse the repository at this point in the history
  • Loading branch information
jedel1043 committed Nov 10, 2023
1 parent c472292 commit 5f83c85
Show file tree
Hide file tree
Showing 13 changed files with 208 additions and 131 deletions.
5 changes: 0 additions & 5 deletions ffi/capi/c/include/ICU4XFixedDecimal.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 0 additions & 10 deletions ffi/capi/cpp/docs/source/fixed_decimal_ffi.rst

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions ffi/capi/cpp/include/ICU4XFixedDecimal.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 0 additions & 17 deletions ffi/capi/cpp/include/ICU4XFixedDecimal.hpp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 0 additions & 28 deletions ffi/capi/dart/package/lib/src/lib.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 0 additions & 10 deletions ffi/capi/js/package/docs/source/fixed_decimal_ffi.rst
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,6 @@
See the `Rust documentation for trunc <https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.FixedDecimal.html#method.trunc>`__ for more information.


.. js:method:: trunc_to_increment(position, increment)

See the `Rust documentation for trunc_to_increment <https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.FixedDecimal.html#method.trunc_to_increment>`__ for more information.


.. js:method:: half_trunc(position)

See the `Rust documentation for half_trunc <https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.FixedDecimal.html#method.half_trunc>`__ for more information.
Expand All @@ -182,11 +177,6 @@
See the `Rust documentation for expand <https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.FixedDecimal.html#method.expand>`__ for more information.


.. js:method:: expand_to_increment(position, increment)

See the `Rust documentation for expand_to_increment <https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.FixedDecimal.html#method.expand_to_increment>`__ for more information.


.. js:method:: half_expand(position)

See the `Rust documentation for half_expand <https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.FixedDecimal.html#method.half_expand>`__ for more information.
Expand Down
13 changes: 0 additions & 13 deletions ffi/capi/js/package/lib/ICU4XFixedDecimal.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { FFIError } from "./diplomat-runtime"
import { ICU4XError } from "./ICU4XError";
import { ICU4XFixedDecimalSign } from "./ICU4XFixedDecimalSign";
import { ICU4XFixedDecimalSignDisplay } from "./ICU4XFixedDecimalSignDisplay";
import { ICU4XRoundingIncrement } from "./ICU4XRoundingIncrement";

/**
Expand Down Expand Up @@ -202,12 +201,6 @@ export class ICU4XFixedDecimal {
*/
trunc(position: i16): void;

/**
* See the {@link https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.FixedDecimal.html#method.trunc_to_increment Rust documentation for `trunc_to_increment`} for more information.
*/
trunc_to_increment(position: i16, increment: ICU4XRoundingIncrement): void;

/**
* See the {@link https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.FixedDecimal.html#method.half_trunc Rust documentation for `half_trunc`} for more information.
Expand All @@ -220,12 +213,6 @@ export class ICU4XFixedDecimal {
*/
expand(position: i16): void;

/**
* See the {@link https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.FixedDecimal.html#method.expand_to_increment Rust documentation for `expand_to_increment`} for more information.
*/
expand_to_increment(position: i16, increment: ICU4XRoundingIncrement): void;

/**
* See the {@link https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.FixedDecimal.html#method.half_expand Rust documentation for `half_expand`} for more information.
Expand Down
9 changes: 0 additions & 9 deletions ffi/capi/js/package/lib/ICU4XFixedDecimal.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import * as diplomatRuntime from "./diplomat-runtime.js"
import { ICU4XError_js_to_rust, ICU4XError_rust_to_js } from "./ICU4XError.js"
import { ICU4XFixedDecimalSign_js_to_rust, ICU4XFixedDecimalSign_rust_to_js } from "./ICU4XFixedDecimalSign.js"
import { ICU4XFixedDecimalSignDisplay_js_to_rust, ICU4XFixedDecimalSignDisplay_rust_to_js } from "./ICU4XFixedDecimalSignDisplay.js"
import { ICU4XRoundingIncrement_js_to_rust, ICU4XRoundingIncrement_rust_to_js } from "./ICU4XRoundingIncrement.js"

const ICU4XFixedDecimal_box_destroy_registry = new FinalizationRegistry(underlying => {
wasm.ICU4XFixedDecimal_destroy(underlying);
Expand Down Expand Up @@ -187,10 +186,6 @@ export class ICU4XFixedDecimal {
wasm.ICU4XFixedDecimal_trunc(this.underlying, arg_position);
}

trunc_to_increment(arg_position, arg_increment) {
wasm.ICU4XFixedDecimal_trunc_to_increment(this.underlying, arg_position, ICU4XRoundingIncrement_js_to_rust[arg_increment]);
}

half_trunc(arg_position) {
wasm.ICU4XFixedDecimal_half_trunc(this.underlying, arg_position);
}
Expand All @@ -199,10 +194,6 @@ export class ICU4XFixedDecimal {
wasm.ICU4XFixedDecimal_expand(this.underlying, arg_position);
}

expand_to_increment(arg_position, arg_increment) {
wasm.ICU4XFixedDecimal_expand_to_increment(this.underlying, arg_position, ICU4XRoundingIncrement_js_to_rust[arg_increment]);
}

half_expand(arg_position) {
wasm.ICU4XFixedDecimal_half_expand(this.underlying, arg_position);
}
Expand Down
32 changes: 0 additions & 32 deletions ffi/capi/src/fixed_decimal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// called LICENSE at the top level of the ICU4X source tree
// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ).

use fixed_decimal::RoundingIncrement;
use fixed_decimal::Sign;
use fixed_decimal::SignDisplay;

Expand Down Expand Up @@ -239,16 +238,6 @@ pub mod ffi {
self.0.trunc(position)
}

#[diplomat::rust_link(fixed_decimal::FixedDecimal::trunc_to_increment, FnInStruct)]
#[diplomat::rust_link(
fixed_decimal::FixedDecimal::trunced_to_increment,
FnInStruct,
hidden
)]
pub fn trunc_to_increment(&mut self, position: i16, increment: ICU4XRoundingIncrement) {
self.0.trunc_to_increment(position, increment.into())
}

#[diplomat::rust_link(fixed_decimal::FixedDecimal::half_trunc, FnInStruct)]
#[diplomat::rust_link(fixed_decimal::FixedDecimal::half_trunced, FnInStruct, hidden)]
pub fn half_trunc(&mut self, position: i16) {
Expand All @@ -261,16 +250,6 @@ pub mod ffi {
self.0.expand(position)
}

#[diplomat::rust_link(fixed_decimal::FixedDecimal::expand_to_increment, FnInStruct)]
#[diplomat::rust_link(
fixed_decimal::FixedDecimal::expanded_to_increment,
FnInStruct,
hidden
)]
pub fn expand_to_increment(&mut self, position: i16, increment: ICU4XRoundingIncrement) {
self.0.expand_to_increment(position, increment.into())
}

#[diplomat::rust_link(fixed_decimal::FixedDecimal::half_expand, FnInStruct)]
#[diplomat::rust_link(fixed_decimal::FixedDecimal::half_expanded, FnInStruct, hidden)]
pub fn half_expand(&mut self, position: i16) {
Expand Down Expand Up @@ -360,14 +339,3 @@ impl From<ffi::ICU4XFixedDecimalSignDisplay> for SignDisplay {
}
}
}

impl From<ffi::ICU4XRoundingIncrement> for RoundingIncrement {
fn from(value: ffi::ICU4XRoundingIncrement) -> Self {
match value {
ffi::ICU4XRoundingIncrement::MultiplesOf1 => RoundingIncrement::MultiplesOf1,
ffi::ICU4XRoundingIncrement::MultiplesOf2 => RoundingIncrement::MultiplesOf2,
ffi::ICU4XRoundingIncrement::MultiplesOf5 => RoundingIncrement::MultiplesOf5,
ffi::ICU4XRoundingIncrement::MultiplesOf25 => RoundingIncrement::MultiplesOf25,
}
}
}
4 changes: 4 additions & 0 deletions tools/ffi_coverage/src/allowlist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,10 @@ lazy_static::lazy_static! {
"icu::relativetime",
"icu::displaynames",
"icu::transliterate",
"fixed_decimal::FixedDecimal::expand_to_increment",
"fixed_decimal::FixedDecimal::expanded_to_increment",
"fixed_decimal::FixedDecimal::trunc_to_increment",
"fixed_decimal::FixedDecimal::trunced_to_increment",

// Stuff that does not need to be exposed over FFI
// Especially for stuff that are Rust specific like conversion traits
Expand Down
1 change: 1 addition & 0 deletions utils/fixed_decimal/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ criterion = "0.4"
[features]
std = []
bench = []
experimental = []
ryu = ["dep:ryu"]

[lib]
Expand Down
Loading

0 comments on commit 5f83c85

Please sign in to comment.