This is an automated email from the ASF dual-hosted git repository. chaokunyang pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/fory-site.git
commit 34e5c7c1976e24a218a4d686224c1cae15b4b538 Author: chaokunyang <[email protected]> AuthorDate: Tue Apr 21 08:18:50 2026 +0000 🔄 synced local 'docs/guide/' with remote 'docs/guide/' --- docs/guide/dart/cross-language.md | 7 ++++--- docs/guide/dart/index.md | 7 ++++--- docs/guide/dart/supported-types.md | 14 +++++++++++++- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/docs/guide/dart/cross-language.md b/docs/guide/dart/cross-language.md index fb8311692..a659c9257 100644 --- a/docs/guide/dart/cross-language.md +++ b/docs/guide/dart/cross-language.md @@ -160,7 +160,7 @@ Fory matches fields by name or by stable field ID. For robust cross-language int 2. Assign stable `@ForyField(id: ...)` values to all fields before shipping the first payload. 3. Keep field names consistent or rely on IDs, since Dart typically uses `lowerCamelCase` while Go uses `PascalCase` for exported fields and C# often uses `PascalCase` properties. 4. Use compatible numeric types: `Int32` in Dart for Java `int`, Go `int32`, and C# `int`; `double` in Dart for 64-bit floats; `Float32` for 32-bit. -5. Use `Timestamp` and `LocalDate` for date/time fields rather than raw `DateTime`. +5. Use `Timestamp`, `LocalDate`, and `Duration` for temporal fields rather than raw `DateTime`. 6. Validate real round trips across all languages before shipping. ## Type Mapping Notes for Dart @@ -169,8 +169,9 @@ Because Dart `int` is not itself a promise about the exact xlang wire width, pre - `Int32` for xlang `int32` - `UInt32` for xlang `uint32` -- `Float16` and `Float32` for reduced-width floating point -- `Timestamp` and `LocalDate` for explicit temporal semantics +- `Float16`, `Bfloat16`, and `Float32` for reduced-width floating point +- `Float16List` and `Bfloat16List` for 16-bit floating-point array payloads +- `Timestamp`, `LocalDate`, and `Duration` for explicit temporal semantics See [Supported Types](supported-types.md) and [xlang type mapping](../../specification/xlang_type_mapping.md). diff --git a/docs/guide/dart/index.md b/docs/guide/dart/index.md index b5517810e..0e814c447 100644 --- a/docs/guide/dart/index.md +++ b/docs/guide/dart/index.md @@ -114,9 +114,10 @@ dart run build_runner build --delete-conflicting-outputs - `fory.deserialize<T>(bytes)` — returns a `T` - `@ForyStruct()` — marks a class for code generation - `@ForyField(...)` — per-field options (skip, ID, nullability, references) -- Integer wrappers: `Int8`, `Int16`, `Int32`, `UInt8`, `UInt16`, `UInt32` -- Float wrappers: `Float16`, `Float32` -- Time wrappers: `LocalDate`, `Timestamp` +- Integer wrappers: `Int8`, `Int16`, `Int32`, `Uint8`, `Uint16`, `Uint32`, `Uint64` +- Float wrappers: `Float16`, `Bfloat16`, `Float32` +- 16-bit float arrays: `Float16List`, `Bfloat16List` +- Time types: `LocalDate`, `Timestamp`, `Duration` ## Documentation diff --git a/docs/guide/dart/supported-types.md b/docs/guide/dart/supported-types.md index a6acc5f2d..ad2b5c273 100644 --- a/docs/guide/dart/supported-types.md +++ b/docs/guide/dart/supported-types.md @@ -54,10 +54,16 @@ Each wrapper clamps the stored value to the target bit width. ## Floating-Point Wrappers -Dart `double` maps to 64-bit float. If the peer uses a 32-bit float, use a wrapper: +Dart `double` maps to 64-bit float. If the peer uses reduced-precision +floating-point values, use an explicit wrapper: - `Float32` — 32-bit float (matches Java `float`, C# `float`, Go `float32`) - `Float16` — half-precision, for specialized numeric payloads +- `Bfloat16` — brain floating point, useful when interoperating with ML-oriented payloads + +For contiguous 16-bit floating-point arrays, use `Float16List` and +`Bfloat16List` rather than `Uint16List` when the wire type is `float16_array` +or `bfloat16_array`. ## Time and Date Types @@ -65,12 +71,18 @@ Avoid sending raw `DateTime` across languages — time zone handling and epoch d - `Timestamp` — a UTC instant with nanosecond precision (seconds + nanoseconds) - `LocalDate` — a calendar date without time or time zone +- `Duration` — an elapsed time value using Dart's built-in `Duration` ```dart final now = Timestamp.fromDateTime(DateTime.now().toUtc()); final birthday = LocalDate(1990, 12, 1); +final timeout = const Duration(seconds: 30); ``` +`Duration` support in Dart is exact to microseconds. Incoming xlang duration +payloads that use sub-microsecond nanoseconds are rejected instead of being +silently truncated. + ## Structs and Enums Annotate classes with `@ForyStruct()` and run `build_runner` to make them serializable. Enums in the same file are included automatically. --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
