Skip to content

Commit

Permalink
Add FFI
Browse files Browse the repository at this point in the history
  • Loading branch information
makotokato committed Oct 18, 2023
1 parent 80b93ae commit 76faf6c
Show file tree
Hide file tree
Showing 17 changed files with 142 additions and 1 deletion.
2 changes: 2 additions & 0 deletions ffi/capi/c/include/ICU4XCodePointMapData8.h

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

2 changes: 2 additions & 0 deletions ffi/capi/c/include/ICU4XPropertyValueNameToEnumMapper.h

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

5 changes: 5 additions & 0 deletions ffi/capi/cpp/docs/source/properties_maps_ffi.rst

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

5 changes: 5 additions & 0 deletions ffi/capi/cpp/docs/source/properties_names_ffi.rst

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

2 changes: 2 additions & 0 deletions ffi/capi/cpp/include/ICU4XCodePointMapData8.h

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

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

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

2 changes: 2 additions & 0 deletions ffi/capi/cpp/include/ICU4XPropertyValueNameToEnumMapper.h

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

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

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

5 changes: 5 additions & 0 deletions ffi/capi/js/docs/source/properties_maps_ffi.rst

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

5 changes: 5 additions & 0 deletions ffi/capi/js/docs/source/properties_names_ffi.rst

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

7 changes: 7 additions & 0 deletions ffi/capi/js/include/ICU4XCodePointMapData8.d.ts

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

17 changes: 17 additions & 0 deletions ffi/capi/js/include/ICU4XCodePointMapData8.js

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

7 changes: 7 additions & 0 deletions ffi/capi/js/include/ICU4XPropertyValueNameToEnumMapper.d.ts

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

17 changes: 17 additions & 0 deletions ffi/capi/js/include/ICU4XPropertyValueNameToEnumMapper.js

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

12 changes: 12 additions & 0 deletions ffi/capi/src/properties_maps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,18 @@ pub mod ffi {
)?))
}

#[diplomat::rust_link(icu::properties::maps::indic_syllabic_category, Fn)]
#[diplomat::rust_link(icu::properties::maps::load_indic_syllabic_category, Fn, hidden)]
pub fn load_indic_syllabic_category(
provider: &ICU4XDataProvider,
) -> Result<Box<ICU4XCodePointMapData8>, ICU4XError> {
Ok(convert_8(call_constructor_unstable!(
maps::indic_syllabic_category [r => Ok(r.static_to_owned())],
maps::load_indic_syllabic_category,
provider,
)?))
}

#[diplomat::rust_link(icu::properties::maps::line_break, Fn)]
#[diplomat::rust_link(icu::properties::maps::load_line_break, Fn, hidden)]
pub fn load_line_break(
Expand Down
20 changes: 19 additions & 1 deletion ffi/capi/src/properties_names.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ pub mod ffi {
use alloc::boxed::Box;
use icu_properties::{
names::PropertyValueNameToEnumMapper, BidiClass, EastAsianWidth, GeneralCategory,
GeneralCategoryGroup, GraphemeClusterBreak, LineBreak, Script, SentenceBreak, WordBreak,
GeneralCategoryGroup, GraphemeClusterBreak, IndicSyllabicCategory, LineBreak, Script,
SentenceBreak, WordBreak,
};

use crate::errors::ffi::ICU4XError;
Expand Down Expand Up @@ -110,6 +111,23 @@ pub mod ffi {
)))
}

#[diplomat::rust_link(
icu::properties::IndicSyllabicCategory::name_to_enum_mapper,
FnInStruct
)]
pub fn load_indic_syllabic_category(
provider: &ICU4XDataProvider,
) -> Result<Box<ICU4XPropertyValueNameToEnumMapper>, ICU4XError> {
Ok(Box::new(ICU4XPropertyValueNameToEnumMapper(
call_constructor_unstable!(
IndicSyllabicCategory::name_to_enum_mapper [r => Ok(r.static_to_owned())],
IndicSyllabicCategory::get_name_to_enum_mapper,
provider,
)?
.erase(),
)))
}

#[diplomat::rust_link(icu::properties::LineBreak::name_to_enum_mapper, FnInStruct)]
pub fn load_line_break(
provider: &ICU4XDataProvider,
Expand Down
1 change: 1 addition & 0 deletions tools/ffi_coverage/src/allowlist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ lazy_static::lazy_static! {
"icu::properties::GeneralCategory",
"icu::properties::GeneralCategoryGroup",
"icu::properties::GraphemeClusterBreak",
"icu::properties::IndicSyllabicCategory",
"icu::properties::LineBreak",
"icu::properties::Script",
"icu::properties::SentenceBreak",
Expand Down

0 comments on commit 76faf6c

Please sign in to comment.