From e731f1a1a4bae33c30a38c7b59711c466258795c Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Thu, 19 Nov 2026 21:58:19 -0800 Subject: [PATCH 1/9] chore(quest): claim quest/m1/ffi-ord.md Quest-Claim: aed84b237322cb2e From a082ac3b93bc91576ce1aa23676046e43052dfeb Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Thu, 19 Nov 2026 22:54:37 -0800 Subject: [PATCH 2/9] feat(ffi): export PartialOrd and Ord in every binding Co-Authored-By: Claude Opus 5.5 --- ffi/README.md | 36 ++-- ffi/fixtures/api/examples/transcript.rs | 39 +++- ffi/fixtures/api/src/lib.rs | 34 ++++ ffi/moq/moq.c | 7 + ffi/moq/moq.cpp | 6 + ffi/moq/moq.dart | 5 + ffi/moq/moq.go | 9 + ffi/moq/moq.kt | 7 + ffi/moq/moq.py | 5 + ffi/moq/moq.swift | 5 + ffi/runtime/rt.hpp | 40 ++++ ffi/runtime/rt.rs | 14 ++ ffi/src/abi.rs | 10 +- ffi/src/c.rs | 20 +- ffi/src/collect.rs | 28 ++- ffi/src/cpp.rs | 103 +++++++++- ffi/src/dart.rs | 51 ++++- ffi/src/glue.rs | 18 ++ ffi/src/go.rs | 65 ++++++- ffi/src/ir.rs | 17 ++ ffi/src/kotlin.rs | 73 ++++++- ffi/src/lock.rs | 4 +- ffi/src/python.rs | 40 +++- ffi/src/swift.rs | 87 ++++++--- ffi/src/web.rs | 30 +++ ffi/surface/api/c.h | 31 ++- ffi/surface/api/cpp.hpp | 78 ++++++++ ffi/surface/api/dart.dart | 61 +++++- ffi/surface/api/go.txt | 31 +++ ffi/surface/api/kotlin.kt | 31 ++- ffi/surface/api/python.pyi | 39 ++++ ffi/surface/api/swift.swift | 49 ++++- ffi/surface/api/web.d.ts | 36 ++++ ffi/surface/moq-web/web.d.ts | 33 ++++ ffi/surface/moq/c.h | 39 +++- ffi/surface/moq/cpp.hpp | 199 ++++++++++++++++++++ ffi/surface/moq/dart.dart | 149 +++++++++++++-- ffi/surface/moq/go.txt | 43 +++++ ffi/surface/moq/kotlin.kt | 70 +++++-- ffi/surface/moq/python.pyi | 76 ++++++++ ffi/surface/moq/swift.swift | 104 ++++++++-- ffi/surface/surface.py | 3 +- ffi/surface/test_surface.py | 2 + ffi/tests/fixtures/transcript/c.rs | 49 +++-- ffi/tests/fixtures/transcript/cpp.rs | 15 ++ ffi/tests/fixtures/transcript/dart.rs | 3 + ffi/tests/fixtures/transcript/go.rs | 38 ++++ ffi/tests/fixtures/transcript/ir.rs | 21 +++ ffi/tests/fixtures/transcript/kotlin.rs | 16 +- ffi/tests/fixtures/transcript/mod.rs | 4 + ffi/tests/fixtures/transcript/parse.rs | 24 ++- ffi/tests/fixtures/transcript/python.rs | 8 + ffi/tests/fixtures/transcript/swift.rs | 10 +- ffi/tests/fixtures/transcript/typescript.rs | 22 ++- quest/m1/ffi-export/README.md | 2 +- quest/m1/ffi-ord.md | 21 --- 56 files changed, 1896 insertions(+), 164 deletions(-) delete mode 100644 quest/m1/ffi-ord.md diff --git a/ffi/README.md b/ffi/README.md index a5462979f..2cc9a7e05 100644 --- a/ffi/README.md +++ b/ffi/README.md @@ -129,8 +129,9 @@ public path names, or an error taken by value, is held by value as an opaque han | `Arc` of another crate's `Send` and `Sync` type that no other rule maps, such as `Arc`, or `Arc` and `&'static dyn Trait` of another crate's trait without generic arguments, whose auto traits are `Send` and `Sync` but those the trait implies, borrowing nothing C lends, as rustls's `Arc` | an opaque object named by `T`'s crate and name, such as `_rustls_ServerConfig`, with `_clone` and `_free` and none of `T`'s API: it only passes back to Rust | | another crate's `Send` and `Sync` type taken or returned by value or lent, with no type parameters, that no other rule maps, that is no iterator or future, and that is not reached by its public path, such as one only a `#[doc(hidden)]` module names, or a standard library type no other rule maps, such as `io::Error`, named by its full path, `_std_io_Error` | an opaque object named as the `Arc` form is, with `_free` and none of `T`'s API, holding the value: Rust takes it back by value, or borrows it; a type also named behind an `Arc` is that form, and refused by value | | a type implementing `PartialEq` and `Hash` | beside `_eq`, `uint64_t _hash`, its `Hash` through std's hasher with its fixed keys, so equal values hash alike in every binding | -| `std::time::Instant` | an object `_Instant`, which only Rust makes, copied into each call that takes it and compared by `_eq`, with none of its methods | -| `tracing::Level` | `_Level`: a C enum of its five levels, `TRACE` to `ERROR` | +| a type implementing `PartialOrd` with itself | `int8_t _partial_cmp(a, b)`: -1, 0, or 1 as `a` is less than, equal to, or greater than `b`, or 2 when the two are unordered; with `Ord`, `int8_t _cmp(a, b)` too, -1, 0, or 1. Every binding's `<` and its kin call `_partial_cmp`, as Rust's do, and its total order, where it has one, `_cmp` | +| `std::time::Instant` | an object `_Instant`, which only Rust makes, copied into each call that takes it and compared by `_eq` and ordered by `_cmp`, with none of its methods | +| `tracing::Level` | `_Level`: a C enum of its five levels, `TRACE` to `ERROR`, ordered by tracing's `Ord`, the more verbose after the less | | `tracing::level_filters::LevelFilter` | `Option`, whose `None` is `OFF` | | `serde_json::Value` | an object `_Json`, made by `_Json_parse` from JSON text, which fails with serde_json's message, and read back by `_to_text`; its contents are the caller's JSON library's to read | | `Vec`, `&[T]`, and `Box<[T]>` of any other `T` | `_vec_`: an array of `T`'s C values, viewed passed in and owned returned, a slice as a clone; of references only returned; a boxed slice of bytes is refused | @@ -176,8 +177,8 @@ is the call's. A signature may not lend C's borrow for one that is `'static`, bu exclusive lend: a `&mut self` method of an object returning an object, bare or as a `Result`'s `Ok`, that borrows the receiver's lifetime alone and is not `Copy`, as a lock's guard does, which its handle holds with the receiver's exclusive borrow; a copy would -carry the borrow past it. Each of its `Clone`, `PartialEq`, `Hash`, `Debug`, `Display`, -`Deref`, and `DerefMut` must hold at every lifetime, as the binding calls them on the +carry the borrow past it. Each of its `Clone`, `PartialEq`, `Hash`, `PartialOrd`, `Ord`, +`Debug`, `Display`, `Deref`, and `DerefMut` must hold at every lifetime, as the binding calls them on the `'static` form, and its `Deref` target must name no lifetime. So must each of the method's own bounds naming the receiver's lifetime, as the binding's lend gives the call a borrow of any lifetime. A parameter is a reference @@ -498,7 +499,10 @@ packages place it in. - **Objects** are classes owning their handle through a `std::unique_ptr` whose deleter calls `_free`, so they move and never copy, and a `Clone` type's `clone()` crosses into Rust for a value of its own. A type implementing `Hash` has `hash()`, Rust's, by which - `std::hash` hashes it. A type whose copies may share one value, by the rule below, + `std::hash` hashes it. Every type implementing `PartialOrd` has `<`, `<=`, `>`, and `>=`, + through Rust's `partial_cmp`, and from C++20 `<=>`: a `std::weak_ordering` through `cmp` + with `Ord`, since Rust's `Equal` promises agreement with `==` alone, and else a + `std::partial_ordering`. A type whose copies may share one value, by the rule below, owns it through a `std::shared_ptr` instead: a copy shares the handle without crossing into Rust, and the last copy frees it, on whichever thread drops it. `&self` methods are `const`, and `self` methods are `&&`, so a call that moves the value out reads @@ -629,7 +633,10 @@ the rest cross encoded. the GC frees it once it collects it, on a daemon thread a phantom reference queue feeds. A `self` method, or passing the object by value, moves its value out and closes it once the call returns. `Clone` is `clone()`, `PartialEq` is `equals`, and `Hash` is `hashCode`, Rust's - hash folded as `Long.hashCode` folds it, or 0 without one. A value that is not `Send` + hash folded as `Long.hashCode` folds it, or 0 without one. `PartialOrd` is + `partialCompareTo`, null when unordered, and `Ord` makes it `Comparable`, whose + `compareTo`, and so `<`, is Rust's `cmp`; an enum class's `compareTo` stays Kotlin's + own by declaration order, which Kotlin makes final. A value that is not `Send` throws an `IllegalStateException` when used on another thread than the one that made it, and closed or collected on another, it drops on its own at its next call or as it exits. A future that is not `Send` made from none lives on a home, so a coroutine a @@ -792,7 +799,7 @@ caller imports it with no ignores. - **Objects** are classes owning their handle, freed once their last reference goes, which the caller's reference keeps through a call, so there is no `close()`. A `self` method, or passing the object by value, moves its value out, after which a call raises - `ValueError`. `Clone` is `clone()`, and `PartialEq` is `==`, unhashable unless the type implements `Hash`, which `hash()` hashes it by. An object, as + `ValueError`. `Clone` is `clone()`, and `PartialEq` is `==`, unhashable unless the type implements `Hash`, which `hash()` hashes it by. `PartialOrd` is `<`, `<=`, `>`, and `>=`, through Rust's `partial_cmp`, each false when the two are unordered. An object, as an opaque value and a record, takes weak references (`weakref.ref`). A field is a property, `first_get`, and its setter a method, `first_set(value)`, named as the C ones, since setting an object moves it in and closes it, which an assignment would hide. @@ -916,7 +923,8 @@ value of a Rust type crosses as one Swift type that holds it exactly, and back u `clamped()`, `clamped(low:)`, `clamped(high:)` and `clamped(low:high:)`, up to two per function; `Option<&mut T>` is `inout T?`. `Clone` is `clone()`, and `PartialEq` is `==`, which Swift 6.4 makes `Equatable` unless it throws, as below, and `Hashable` with `Hash`, whose `hash(into:)` - combines Rust's hash; `Display` is `description` and `Debug` + combines Rust's hash; `PartialOrd` is `<`, `<=`, `>`, and `>=`, through Rust's + `partial_cmp`, and with `Ord` makes it `Comparable` unless it throws; `Display` is `description` and `Debug` `debugDescription`, which Swift conforms no noncopyable type to yet. A `Copy` object, which Rust copies where it takes one by value, and an object thrown as an error, which `Swift.Error` requires be copyable, are final classes instead, whose handle a call @@ -1114,7 +1122,9 @@ other than one in its own form, `module ` and `go 1.24`. variant (`ShapeSquare`). An enum with data is an interface each variant's struct implements (`EventMoved{V0: p}`), sealed so only the package's do; its methods are the interface's. Positional fields are `V0`, `V1`, and so on. `Display` is `String()`, - `Debug` `GoString()`, `PartialEq` `Equal(other)`, all through Rust's, and `Default` a + `Debug` `GoString()`, `PartialEq` `Equal(other)`, `PartialOrd` `PartialCompare(other)`, + -1, 0, or 1 and false when unordered, and `Ord` `Compare(other)`, the shape + `slices.SortFunc` takes, all through Rust's, and `Default` a function of the package, `PointDefault()`. An object's exported `Handle_` field, and a trait's `Vtable_` function, are how one generated package reaches another's, since cgo gives each its own C types: callers use neither. An **opaque value** is a @@ -1249,7 +1259,9 @@ the library's own URI, mapped to the library by a build hook or by `--native-ass with data a sealed class with a final class per variant (`EventMoved`), so a `switch` over it is exhaustive. `Display` is `toString()`, `Debug` `debug()`, `PartialEq` `==`, and `Hash` `hashCode`, all through Rust's; without `Hash`, `hashCode` throws an - `UnsupportedError`, since no hash Dart computes agrees with Rust's `==`. `Default` is a + `UnsupportedError`, since no hash Dart computes agrees with Rust's `==`. `PartialOrd` is + `<`, `<=`, `>`, `>=`, and `partialCompareTo`, null when unordered, through Rust's + `partial_cmp`, and `Ord` makes it `Comparable`, whose `compareTo` is Rust's `cmp`. `Default` is a constructor, `default_()`. An **opaque value** is a final class of its bytes as `int`s, with a private constructor, so only Rust makes one. It never changes: a `&mut self` method, a field's setter @@ -1502,7 +1514,9 @@ packs the api fixture's with npm, installs it into a project of its own, type-ch once it drops an implementation, and **closures** are functions: each is a C function the module imports from `rust2`, whose data is a token the binding finds the value by, so JavaScript never writes the module's function table. Its std traits are functions of its - module: `toString`, `debug`, an object's `clone`, `eq`, with `Hash` `hash`, and `default`. + module: `toString`, `debug`, an object's `clone`, `eq`, with `Hash` `hash`, `partialCmp` + from `PartialOrd`, undefined when unordered, `cmp` from `Ord`, the shape + `Array.prototype.sort` takes, and `default`. - **Futures** are an `rt.Call`, a `Promise` with `cancel()`: the call polls once as it is made, and each wake polls again on a microtask, never inside the wake. Cancelling frees the future in Rust, losing nothing, and rejects with `rt.Cancelled`. A future JavaScript diff --git a/ffi/fixtures/api/examples/transcript.rs b/ffi/fixtures/api/examples/transcript.rs index 9368cddd7..3dc23d714 100644 --- a/ffi/fixtures/api/examples/transcript.rs +++ b/ffi/fixtures/api/examples/transcript.rs @@ -15,7 +15,7 @@ use std::task::{Context, Poll, Wake, Waker}; use api::{ Channel, Counter, Event, LIMIT, Label, Log, Logger, Message, Name, Node, Pair, Point, Registry, Shape, Size, Stack, - Stamp, Tally, Waiter, Window, + Stamp, Tally, Tier, Version, Waiter, Window, }; use bytes::Bytes; @@ -961,6 +961,43 @@ fn main() { a.hash_of() == api::Key::new("a").hash_of(), a.hash_of() == b.hash_of() ); + // A version orders by its derived `Ord`, and its `<` by `PartialOrd`, which agrees. + let (v1, v2) = (Version { major: 1, minor: 2 }, Version { major: 1, minor: 10 }); + println!( + "version {} {} {} {} {} {} {}", + v1 < v2, + v1 <= v2, + v1 > v2, + v1 >= v2, + v1.cmp(&v2) as i8, + v2.cmp(&v1) as i8, + v1.cmp(&v1) as i8 + ); + // A quantity orders by its hand-written `PartialOrd`, which leaves two units unordered. + let (m1, m2, g1) = ( + api::Quantity::new(1, 'm'), + api::Quantity::new(2, 'm'), + api::Quantity::new(1, 'g'), + ); + println!( + "quantity {} {} {} {} {} {} {} {} {}", + m1 < m2, + m1 <= m2, + m1 > m2, + m1 >= m2, + m1 <= api::Quantity::new(1, 'm'), + m1 < g1, + m1 <= g1, + m1 > g1, + m1 >= g1 + ); + println!( + "tier {} {} {} {}", + Tier::Low < Tier::High, + Tier::Low >= Tier::Low, + Tier::High.cmp(&Tier::Low) as i8, + Tier::Low.cmp(&Tier::High) as i8 + ); println!( "lossless ip {} {}", ip_hex(api::same_ip_addr("255.255.255.255".parse().unwrap())), diff --git a/ffi/fixtures/api/src/lib.rs b/ffi/fixtures/api/src/lib.rs index 153b091ef..eb58bdb82 100644 --- a/ffi/fixtures/api/src/lib.rs +++ b/ffi/fixtures/api/src/lib.rs @@ -5066,6 +5066,40 @@ pub fn same_ip_addr(v: std::net::IpAddr) -> std::net::IpAddr { v } +/// A version: a record whose derived `Ord` is a total order, `major` first. +#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)] +pub struct Version { + pub major: u16, + pub minor: u16, +} + +/// A quantity: an object whose hand-written `PartialOrd` leaves quantities of two units +/// unordered, as moq's timestamps of two scales are, so it has no `Ord`. +#[derive(Debug, PartialEq)] +pub struct Quantity { + value: i64, + unit: char, +} + +impl Quantity { + pub fn new(value: i64, unit: char) -> Quantity { + Quantity { value, unit } + } +} + +impl PartialOrd for Quantity { + fn partial_cmp(&self, other: &Self) -> Option { + (self.unit == other.unit).then(|| self.value.cmp(&other.value)) + } +} + +/// A tier: an enum whose derived `Ord` orders its variants as declared. +#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)] +pub enum Tier { + Low, + High, +} + /// A key: an object whose `Hash` agrees with its `PartialEq`, so a binding hashes it by /// Rust's, as a map keyed by it needs. #[derive(Clone, Debug, PartialEq, Eq, Hash)] diff --git a/ffi/moq/moq.c b/ffi/moq/moq.c index cf65f7550..2eed5cb6c 100644 --- a/ffi/moq/moq.c +++ b/ffi/moq/moq.c @@ -224,6 +224,13 @@ int main(void) { uint64_t secs = 0; CHECK(moq_Timestamp_from_millis(1500, &at, &overflow)); CHECK(moq_Timestamp_as_secs(at, &secs, &overflow, NULL) && secs == 1); + /* Timestamps order in time across scales, and a scaled one and an unscaled key not at all. */ + moq_Timestamp *second = NULL; + CHECK(moq_Timestamp_from_secs(1, &second, &overflow)); + CHECK(moq_Timestamp_partial_cmp(second, at, NULL) == -1); + CHECK(moq_Timestamp_partial_cmp(at, second, NULL) == 1); + CHECK(moq_Timestamp_partial_cmp(key, at, NULL) == 2); + moq_Timestamp_free(second); CHECK(!moq_group_Producer_write_frame(writer, at, str("late"), &err, NULL)); CHECK(err != NULL && is(moq_Error_to_string(err, NULL), "frame timestamp doesn't fit its track")); moq_Error_free(err); diff --git a/ffi/moq/moq.cpp b/ffi/moq/moq.cpp index eb4ef8b59..7ad2ce20f 100644 --- a/ffi/moq/moq.cpp +++ b/ffi/moq/moq.cpp @@ -165,6 +165,12 @@ int main() { // so a timed frame is refused. auto at = moq::Timestamp::from_millis(1500); CHECK(at && at->as_secs() && *at->as_secs() == 1); + // Timestamps order in time across scales, and a scaled one and an unscaled key not at all. + { + auto second = moq::Timestamp::from_secs(1); + auto key = moq::Timestamp::unscaled(0); + CHECK(second && *second < *at && *at > *second && !(key < *at) && !(key >= *at)); + } auto late = writer->write_frame(*at, "late"); CHECK(!late && is(late.error().to_string(), "frame timestamp doesn't fit its track")); CHECK(at->as_secs() && *at->as_secs() == 1); diff --git a/ffi/moq/moq.dart b/ffi/moq/moq.dart index 4823207d9..1913703a8 100644 --- a/ffi/moq/moq.dart +++ b/ffi/moq/moq.dart @@ -125,6 +125,11 @@ Future local() async { // so a timed frame is refused. final at = moq.Timestamp.fromMillis(moq.U64(1500)); expect(at.asSecs() == moq.U64(1), '1500 ms is 1 s'); + // Timestamps order in time across scales, and a scaled one and an unscaled key not at all. + final second = moq.Timestamp.fromSecs(moq.U64(1)); + final key = moq.Timestamp.unscaled(moq.U64(0)); + expect(second < at && at > second && second.partialCompareTo(at) == -1, '1 s is before 1500 ms'); + expect(!(key < at) && !(key >= at) && key.partialCompareTo(at) == null, 'an unscaled key is unordered against a time'); throws( () => writer.writeFrame(at, utf8.encode('late')), (e) => '$e' == "frame timestamp doesn't fit its track", diff --git a/ffi/moq/moq.go b/ffi/moq/moq.go index 270c50c9e..1e8473cde 100644 --- a/ffi/moq/moq.go +++ b/ffi/moq/moq.go @@ -166,6 +166,15 @@ func script() { // untimed, so a timed frame is refused. at := must(net.TimestampFromMillis(1500)) expect(must(at.AsSecs()) == 1, "1500 ms is 1 s") + // Timestamps order in time across scales, and a scaled one and an unscaled key not at all. + second := must(net.TimestampFromSecs(1)) + key := net.TimestampUnscaled(0) + order, ordered, err := second.PartialCompare(at) + expect(err == nil && ordered && order == -1, "1 s is before 1500 ms") + _, ordered, err = key.PartialCompare(at) + expect(err == nil && !ordered, "an unscaled key is unordered against a time") + second.Close() + key.Close() err = writer.WriteFrame(at, rt.NewBytes([]byte("late"))) expect(errors.As(err, &merr) && err.Error() == "frame timestamp doesn't fit its track", "the late frame's error is Rust's") expect(must(at.AsSecs()) == 1, "a lent timestamp stays usable") diff --git a/ffi/moq/moq.kt b/ffi/moq/moq.kt index e1d1a0cee..120ba557b 100644 --- a/ffi/moq/moq.kt +++ b/ffi/moq/moq.kt @@ -92,6 +92,13 @@ fun main() { // so a timed frame is refused. val at = Timestamp.fromMillis(1500u) expect(at.asSecs() == 1uL, "1500 ms is 1 s") + // Timestamps order in time across scales, and a scaled one and an unscaled key not at all. + Timestamp.fromSecs(1u).use { second -> + Timestamp.unscaled(0u).use { key -> + expect(second.partialCompareTo(at) == -1 && at.partialCompareTo(second) == 1, "1 s is before 1500 ms") + expect(key.partialCompareTo(at) == null, "an unscaled key is unordered against a time") + } + } try { writer.writeFrame(at, Bytes("late".encodeToByteArray())) expect(false, "a timed frame on an untimed track is an error") diff --git a/ffi/moq/moq.py b/ffi/moq/moq.py index 4ff6e52b0..2466518e4 100644 --- a/ffi/moq/moq.py +++ b/ffi/moq/moq.py @@ -89,6 +89,11 @@ def local(loop): # so a timed frame is refused. at = moq.Timestamp.from_millis(1500) expect(at.as_secs() == 1, "1500 ms is 1 s") + # Timestamps order in time across scales, and a scaled one and an unscaled key not at all. + second = moq.Timestamp.from_secs(1) + key = moq.Timestamp.unscaled(0) + expect(second < at and at > second, "1 s is before 1500 ms") + expect(not key < at and not key >= at, "an unscaled key is unordered against a time") try: writer.write_frame(at, b"late") expect(False, "a timed frame on an untimed track is an error") diff --git a/ffi/moq/moq.swift b/ffi/moq/moq.swift index 2a8e344c7..2e26ae282 100644 --- a/ffi/moq/moq.swift +++ b/ffi/moq/moq.swift @@ -256,6 +256,11 @@ func script() throws { // so a timed frame is refused. let at = try Timestamp.fromMillis(1500) expect(try at.asSecs() == 1, "1500 ms is 1 s") + // Timestamps order in time across scales, and a scaled one and an unscaled key not at all. + let second = try Timestamp.fromSecs(1) + let key = Timestamp.unscaled(0) + expect(try second < at && at > second, "1 s is before 1500 ms") + expect(try !(key < at) && !(key >= at), "an unscaled key is unordered against a time") do { try writer.writeFrame(at, Bytes("late".utf8)) expect(false, "a timed frame on an untimed track is an error") diff --git a/ffi/runtime/rt.hpp b/ffi/runtime/rt.hpp index 029533ad3..6e300337f 100644 --- a/ffi/runtime/rt.hpp +++ b/ffi/runtime/rt.hpp @@ -33,6 +33,46 @@ namespace detail { struct access; +// The operators of a `partial_cmp`'s result: -1 less, 0 equal, 1 greater, or 2 when +// unordered, which none of them is. +inline bool less(::std::int8_t c) noexcept { + return c == -1; +} + +inline bool less_equal(::std::int8_t c) noexcept { + return c == -1 || c == 0; +} + +inline bool greater(::std::int8_t c) noexcept { + return c == 1; +} + +inline bool greater_equal(::std::int8_t c) noexcept { + return c == 0 || c == 1; +} + +#if defined(__cpp_lib_three_way_comparison) +// A `partial_cmp`'s result as C++20's ordering of it. +inline ::std::partial_ordering partial_ordering(::std::int8_t c) noexcept { + switch (c) { + case -1: + return ::std::partial_ordering::less; + case 0: + return ::std::partial_ordering::equivalent; + case 1: + return ::std::partial_ordering::greater; + default: + return ::std::partial_ordering::unordered; + } +} + +// An `Ord`'s `cmp`: weak, since Rust's `Equal` promises agreement with `==` alone, not +// that equal values can stand in for each other. +inline ::std::weak_ordering weak_ordering(::std::int8_t c) noexcept { + return c < 0 ? ::std::weak_ordering::less : c > 0 ? ::std::weak_ordering::greater : ::std::weak_ordering::equivalent; +} +#endif + // A `[u8; N]`'s C struct, of its bytes, and back. template C lower_array(const ::std::array<::std::uint8_t, N> &a) noexcept { static_assert(sizeof(C::items) == N, "an array's C struct holds its N bytes"); diff --git a/ffi/runtime/rt.rs b/ffi/runtime/rt.rs index 21ee82a24..b4aec593a 100644 --- a/ffi/runtime/rt.rs +++ b/ffi/runtime/rt.rs @@ -38,6 +38,20 @@ pub fn hash(value: &T) -> u64 { std::hash::BuildHasher::hash_one(&std::hash::BuildHasherDefault::::default(), value) } +/// `a`'s `PartialOrd` against `b`, as C reads it: -1 less, 0 equal, 1 greater, or 2 when +/// they are unordered. +pub fn partial_cmp(a: &T, b: &T) -> i8 { + match a.partial_cmp(b) { + Some(ordering) => ordering as i8, + None => 2, + } +} + +/// `a`'s `Ord` against `b`: -1 less, 0 equal, or 1 greater. +pub fn cmp(a: &T, b: &T) -> i8 { + a.cmp(b) as i8 +} + /// Abort with a message naming the C function whose contract was broken. #[cold] pub fn fail(what: &str, msg: &str) -> ! { diff --git a/ffi/src/abi.rs b/ffi/src/abi.rs index aabb51708..76739675d 100644 --- a/ffi/src/abi.rs +++ b/ffi/src/abi.rs @@ -16,7 +16,9 @@ use std::collections::{BTreeMap, HashMap}; use rustc_span::Span; -use crate::ir::{Access, Api, Closure, Dyn, Family, Function, Home, Int, Jni, Literal, Mutability, On, Receiver, Type}; +use crate::ir::{ + Access, Api, Closure, Dyn, Family, Function, Home, Int, Jni, Literal, Mutability, On, Order, Receiver, Type, +}; /// A C name one item claims twice, which no rename can tell apart: the name, then what /// claimed it first and second. @@ -1833,6 +1835,12 @@ impl<'a> Abi<'a> { if traits.hash { claim("hash"); } + if traits.ord != Order::None { + claim("partial_cmp"); + } + if traits.ord == Order::Total { + claim("cmp"); + } if traits.display { claim("to_string"); } diff --git a/ffi/src/c.rs b/ffi/src/c.rs index fb612bfef..8ca603f2a 100644 --- a/ffi/src/c.rs +++ b/ffi/src/c.rs @@ -6,7 +6,7 @@ use std::hash::Hasher; use rustc_data_structures::stable_hash::StableHasher; use crate::abi::{self, Abi, Sig, Ty}; -use crate::ir::{Function, Int, Literal, Receiver, Traits, Type}; +use crate::ir::{Function, Int, Literal, Order, Receiver, Traits, Type}; /// The header for `abi`, as `.h`, its contract: a hash of what it declares, which /// the library returns from `_contract`, and the C names it gives each item. @@ -332,6 +332,11 @@ impl Header<'_> { if t.hash { self.line(format!("uint64_t {name}_hash(const {name} *self{status});")); } + for suffix in comparisons(t.ord) { + self.line(format!( + "int8_t {name}_{suffix}(const {name} *a, const {name} *b{status});" + )); + } if t.display { self.line(format!("{p}_buf {name}_to_string(const {name} *self{status});")); } @@ -503,6 +508,9 @@ impl Header<'_> { if traits.hash { self.line(format!("uint64_t {name}_hash({this}{status});")); } + for suffix in comparisons(traits.ord) { + self.line(format!("int8_t {name}_{suffix}({a}, {b}{status});")); + } if traits.display { self.line(format!("{p}_buf {name}_to_string({this}{status});")); } @@ -688,6 +696,16 @@ fn comment(docs: &str, indent: &str) -> String { out } +/// The C suffixes of the comparisons a type ordered by `ord` exports: `partial_cmp` for any +/// `PartialOrd`, and `cmp` too for `Ord`. +pub(crate) fn comparisons(ord: Order) -> &'static [&'static str] { + match ord { + Order::None => &[], + Order::Partial => &["partial_cmp"], + Order::Total => &["partial_cmp", "cmp"], + } +} + fn has(traits: Traits) -> bool { traits.eq || traits.display || traits.debug || traits.default } diff --git a/ffi/src/collect.rs b/ffi/src/collect.rs index bdb1c138b..131861854 100644 --- a/ffi/src/collect.rs +++ b/ffi/src/collect.rs @@ -31,7 +31,7 @@ use rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt as _ use crate::config; use crate::ir::{ Access, Api, Callback, Closure, Collection, Constant, Dyn, Enum, Family, Field, Function, Held, Home, Int, Jni, - Literal, Mutability, Object, On, Param, Path, Receiver, Record, Task, TaskKind, Traits, Type, Variant, + Literal, Mutability, Object, On, Order, Param, Path, Receiver, Record, Task, TaskKind, Traits, Type, Variant, }; /// Why something is refused: a construct, ranked by the census, and what it names. @@ -1815,10 +1815,12 @@ impl<'tcx> Collector<'tcx> { methods: Vec::new(), // Its `Debug` is left out: Dart would name it as it names the `Debug` level, // and it prints only what `Display` and the variant's name already say. + // Its `Ord` puts the more verbose level after the less. traits: Traits { clone: true, eq: true, hash: true, + ord: Order::Total, display: true, debug: false, default: false, @@ -1943,6 +1945,7 @@ impl<'tcx> Collector<'tcx> { clone: true, eq: true, hash: true, + ord: Order::Total, debug: true, ..Traits::default() }, @@ -1954,6 +1957,7 @@ impl<'tcx> Collector<'tcx> { clone: true, eq: true, hash: true, + ord: Order::Total, display: true, debug: true, default: false, @@ -2980,6 +2984,13 @@ impl<'tcx> Collector<'tcx> { .must_apply_modulo_regions() }) }; + // `PartialOrd` with itself, as `PartialEq` is. + let partial_ord = tcx.lang_items().partial_ord_trait().is_some_and(|tr| { + let (infcx, env) = tcx.infer_ctxt().build_with_typing_env(env); + infcx + .type_implements_trait(tr, [self_ty, self_ty], env) + .must_apply_modulo_regions() + }); let mut traits = Traits { clone: implements(sym::Clone), eq: tcx.lang_items().eq_trait().is_some_and(|tr| { @@ -2989,6 +3000,11 @@ impl<'tcx> Collector<'tcx> { .must_apply_modulo_regions() }), hash: implements(sym::Hash), + ord: match (partial_ord, implements(sym::Ord)) { + (false, _) => Order::None, + (true, false) => Order::Partial, + (true, true) => Order::Total, + }, display: implements(sym::Display), debug: implements(sym::Debug), default: implements(sym::Default), @@ -5161,6 +5177,8 @@ impl<'tcx> Collector<'tcx> { sym::Clone, sym::PartialEq, sym::Hash, + sym::PartialOrd, + sym::Ord, sym::Debug, rustc_span::sym::Display, ]; @@ -5168,7 +5186,13 @@ impl<'tcx> Collector<'tcx> { .chain(lang.deref_trait()) .chain(lang.deref_mut_trait()) .collect(); - let trait_ref = |tr: DefId, ty: Ty<'tcx>| match Some(tr) == tcx.get_diagnostic_item(sym::PartialEq) { + // The comparisons take the type twice, as `Self` and as the other side. + let paired = |tr: DefId| { + [sym::PartialEq, sym::PartialOrd] + .iter() + .any(|&name| Some(tr) == tcx.get_diagnostic_item(name)) + }; + let trait_ref = |tr: DefId, ty: Ty<'tcx>| match paired(tr) { true => ty::TraitRef::new(tcx, tr, [ty, ty]), false => ty::TraitRef::new(tcx, tr, [ty]), }; diff --git a/ffi/src/cpp.rs b/ffi/src/cpp.rs index ec18dd1e1..291988c4f 100644 --- a/ffi/src/cpp.rs +++ b/ffi/src/cpp.rs @@ -25,7 +25,7 @@ use std::collections::{BTreeMap, BTreeSet}; use crate::abi::{self, Abi, Ty}; use crate::c::decl; -use crate::ir::{Closure, Family, Function, Int, Literal, Receiver, Traits, Type}; +use crate::ir::{Closure, Family, Function, Int, Literal, Order, Receiver, Traits, Type}; const RUNTIME: &str = include_str!("../runtime/rt.hpp"); @@ -36,6 +36,28 @@ pub(crate) struct Output { pub(crate) names: BTreeMap, } +/// A comparison operator: its signature, its body, and whether it is C++20's alone. +struct Operator { + head: String, + body: String, + cpp20: bool, +} + +impl Operator { + /// `text` inside the guard of a C++20 operator. + fn guarded(&self, text: String) -> String { + match self.cpp20 { + true => format!("#if defined(__cpp_lib_three_way_comparison)\n{text}\n#endif"), + false => text, + } + } + + /// Its definition, inline as a friend defined in its class is. + fn define(&self, prefix: &str) -> String { + self.guarded(format!("{prefix}{} {{\n{}}}", self.head, self.body)) + } +} + /// The headers for `abi`: the umbrella `.hpp`, the shared `/rt.hpp`, and a /// `/.hpp` per crate; or the members two items name alike. pub(crate) fn headers(abi: &Abi<'_>, packages: &str) -> Result { @@ -151,6 +173,39 @@ impl<'a> Header<'a> { (a, b) } + /// The comparison operators of a type ordered by `ord`, each taking `params`, whose + /// body runs the first of what `call` gives of a C suffix and returns through the + /// second, the C call: `<` and its kin from `partial_cmp`, as Rust's are, and from + /// C++20 `<=>`, from `cmp` with `Ord` and else from `partial_cmp`. + fn orders(&self, ord: Order, params: &str, call: &dyn Fn(&str) -> (String, String)) -> Vec { + let d = self.d(); + let (pre, partial) = call("partial_cmp"); + let mut ops: Vec = [ + ("<", "less"), + ("<=", "less_equal"), + (">", "greater"), + (">=", "greater_equal"), + ] + .into_iter() + .map(|(op, test)| Operator { + head: format!("bool operator{op}({params})"), + body: format!("{pre}\treturn {d}::{test}({partial});\n"), + cpp20: false, + }) + .collect(); + let (ordering, suffix) = match ord { + Order::Total => ("weak_ordering", "cmp"), + _ => ("partial_ordering", "partial_cmp"), + }; + let (pre, compare) = call(suffix); + ops.push(Operator { + head: format!("::std::{ordering} operator<=>({params})"), + body: format!("{pre}\treturn {d}::{ordering}({compare});\n"), + cpp20: true, + }); + ops + } + /// `name`, declared in the namespace. fn global(&mut self, name: &str) -> String { self.globals.insert(name.to_string()); @@ -555,7 +610,7 @@ impl<'a> Header<'a> { self.line(format!("#include <{include}>")); } self.line( - "#if defined(__cpp_impl_coroutine) && __cpp_impl_coroutine >= 201902L && __has_include()\n#include \n#endif\n", + "#if defined(__cpp_impl_coroutine) && __cpp_impl_coroutine >= 201902L && __has_include()\n#include \n#endif\n#if defined(__cpp_impl_three_way_comparison) && __cpp_impl_three_way_comparison >= 201907L && __has_include()\n#include \n#endif\n", ); self.line(format!("namespace {ns} {{\n")); // Whether a call makes a value that is not `Send`, whose thread an executor drains. @@ -969,6 +1024,22 @@ impl<'a> Header<'a> { "\tfriend bool operator==(const {name} &{a}, const {name} &{b}) {{\n\t\treturn ::{c}_eq({a}.raw_.get(), {b}.raw_.get(){status});\n\t}}\n\tfriend bool operator!=(const {name} &{a}, const {name} &{b}) {{\n\t\treturn !({a} == {b});\n\t}}" )); } + if t.ord != Order::None { + let (a, b) = self.operands(); + let ops = self.orders(t.ord, &format!("const {name} &{a}, const {name} &{b}"), &|suffix| { + ( + String::new(), + format!("::{c}_{suffix}({a}.raw_.get(), {b}.raw_.get(){status})"), + ) + }); + for op in ops { + body.push(op.guarded(format!( + "\tfriend {} {{\n\t{}\n\t}}", + op.head, + op.body.trim_end().replace('\n', "\n\t") + ))); + } + } if t.hash { let hash = apart("hash", &name); body.push(format!( @@ -1204,6 +1275,22 @@ impl<'a> Header<'a> { self.value_status(ty), )); } + if t.ord != Order::None { + let (a, b) = self.operands(); + let (scope, status) = (self.scope([ty]), self.value_status(ty)); + let (lower_a, lower_b) = (self.lower(ty, &a), self.lower(ty, &b)); + let ops = self.orders(t.ord, &format!("const {name} &{a}, const {name} &{b}"), &|suffix| { + ( + format!("{scope}\tauto c_a_ = {lower_a};\n\tauto c_b_ = {lower_b};\n"), + format!("::{c}_{suffix}(&c_a_, &c_b_{status})"), + ) + }); + // Declared friends, as `==` is, and defined after the class. + for op in ops { + body.push(op.guarded(format!("\tfriend {};", op.head))); + self.def(format!("{}\n", op.define("inline "))); + } + } self.traits(&name, &c, t, Err(ty), &mut body, &mut members); let owner = Ty::Struct(c.clone()); let mut taken = fields.clone(); @@ -1290,6 +1377,18 @@ impl<'a> Header<'a> { "inline bool operator==({a_}, {b_}) {{\n{scope}\tauto c_a_ = {lower_a};\n\tauto c_b_ = {lower_b};\n\treturn ::{c}_eq(&c_a_, &c_b_{status});\n}}\n\ninline bool operator!=({a_}, {b_}) {{\n\treturn !({a} == {b});\n}}\n" )); } + if t.ord != Order::None { + let (a_, b_) = (declare(¶m, &a), declare(¶m, &b)); + let ops = self.orders(t.ord, &format!("{a_}, {b_}"), &|suffix| { + ( + format!("{scope}\tauto c_a_ = {lower_a};\n\tauto c_b_ = {lower_b};\n"), + format!("::{c}_{suffix}(&c_a_, &c_b_{status})"), + ) + }); + for op in ops { + self.def(format!("{}\n", op.define("inline "))); + } + } for (on, trait_name) in [(t.display, "to_string"), (t.debug, "debug")] { if on { self.def(format!( diff --git a/ffi/src/dart.rs b/ffi/src/dart.rs index 2b2f992a8..4fa8acf7c 100644 --- a/ffi/src/dart.rs +++ b/ffi/src/dart.rs @@ -83,6 +83,7 @@ pub(crate) fn generate(abi: &Abi<'_>, packages: &str, contract: u64) -> Result { thrown: BTreeMap, /// The exported types thrown as errors, which implement `Exception`. conforms: BTreeSet, + /// The exported types ordered by `Ord`, which implement `Comparable`. + comparables: BTreeSet, /// Each C signature of a lent function, whose relay is `_fn_`. relays: Vec, /// Each closure type, whose trampoline is `_t`. @@ -1457,15 +1460,24 @@ impl<'a> Gen<'a> { "/// A `{dt}` Rust returned as an error.\nfinal class {name} implements Exception {{\n\tfinal {dt} error;\n\n\tconst {name}(this.error);\n\n\t@override\n\tString toString() => '$error';\n}}\n\n" ); } - // Each exported type thrown as an error implements `Exception`, which its - // declaration names once all are known. - for name in &self.conforms.clone() { + // Each exported type thrown as an error implements `Exception`, and each ordered by + // `Ord` `Comparable`, which its declaration names once all are known. + let names: BTreeSet = self.conforms.union(&self.comparables).cloned().collect(); + for name in &names { + let interfaces: Vec = [ + self.conforms.contains(name).then(|| "Exception".to_string()), + self.comparables.contains(name).then(|| format!("Comparable<{name}>")), + ] + .into_iter() + .flatten() + .collect(); for marker in [format!("class {name} "), format!("enum {name} ")] { let at = self.types.find(&format!("{marker}{{")); let at = at.or_else(|| self.types.find(&format!("{marker}extends _Object {{"))); if let Some(at) = at { let open = at + self.types[at..].find('{').expect("a body"); - self.types.insert_str(open, "implements Exception "); + self.types + .insert_str(open, &format!("implements {} ", interfaces.join(", "))); break; } } @@ -1670,6 +1682,37 @@ impl<'a> Gen<'a> { )); } } + // Rust's `partial_cmp`, -1, 0, 1, or 2 when unordered, behind `partialCompareTo` and + // `<` and its kin, as Rust's are; with `Ord`, its `cmp` as `Comparable`'s `compareTo`. + for &suffix in crate::c::comparisons(t.ord) { + let what = format!("{c}_{suffix}"); + let f = self.served_fn(&what, params(vec![recv.clone(), recv.clone()]), Ty::Int(Int::I8)); + let (pa, a) = this(self, "this"); + let (pb, b) = this(self, "other"); + let compare = arena( + false, + format!( + "{pa}{pb}{}", + call(&f, &format!("_n.home, {a}, {b}"), &what, &|r| r.to_string()) + ), + ); + match suffix { + "cmp" => { + members.push("compareTo".to_string()); + self.comparables.insert(name.clone()); + body.push(format!( + "\t/// Rust's `Ord`: -1, 0, or 1 as this is less than, equal to, or greater than [other].\n\t@override\n\tint compareTo({name} other) {{\n\t\t{compare}\n\t}}\n" + )); + } + _ => { + members.push("partialCompareTo".to_string()); + members.push("_partialCmp".to_string()); + body.push(format!( + "\t/// Rust's `partial_cmp`: -1, 0, 1, or 2 when unordered.\n\tint _partialCmp({name} other) {{\n\t\t{compare}\n\t}}\n\n\t/// Rust's `PartialOrd`: -1, 0, or 1 as this is less than, equal to, or greater than [other], or null when the two are unordered.\n\tint? partialCompareTo({name} other) {{\n\t\tfinal c_ = _partialCmp(other);\n\t\treturn c_ == 2 ? null : c_;\n\t}}\n\n\tbool operator <({name} other) => _partialCmp(other) == -1;\n\n\tbool operator <=({name} other) {{\n\t\tfinal c_ = _partialCmp(other);\n\t\treturn c_ == -1 || c_ == 0;\n\t}}\n\n\tbool operator >({name} other) => _partialCmp(other) == 1;\n\n\tbool operator >=({name} other) {{\n\t\tfinal c_ = _partialCmp(other);\n\t\treturn c_ == 0 || c_ == 1;\n\t}}\n" + )); + } + } + } if t.default { members.push("new default_".to_string()); let ret = match object { diff --git a/ffi/src/glue.rs b/ffi/src/glue.rs index bed53f3da..8c558138a 100644 --- a/ffi/src/glue.rs +++ b/ffi/src/glue.rs @@ -1573,6 +1573,18 @@ impl Gen<'_> { "#[unsafe(no_mangle)]\npub unsafe extern \"C\" fn {name}_hash(this: {handle}{param}) -> u64 {{\n\tlet w = \"{name}_hash\";\n\t{away}{body}\n}}\n" )); } + // Each comparison is the runtime's of the same name, which encodes Rust's `Ordering`. + for suffix in crate::c::comparisons(traits.ord) { + let body = wrap( + status, + "i8", + &format!("let a = {a};\n\tlet b = {b};\n\trt::{suffix}::<{path}>({deref}a, {deref}b)"), + ); + let away = away(&format!("{name}_{suffix}"), &["a", "b"]); + self.export(format!( + "#[unsafe(no_mangle)]\npub unsafe extern \"C\" fn {name}_{suffix}(a: {handle}, b: {handle}{param}) -> i8 {{\n\tlet w = \"{name}_{suffix}\";\n\t{away}{body}\n}}\n" + )); + } if traits.display { let body = wrap( status, @@ -1659,6 +1671,12 @@ impl Gen<'_> { "#[unsafe(no_mangle)]\npub unsafe extern \"C\" fn {name}_hash(this: *const {c}{param}) -> u64 {{\n\tlet w = \"{name}_hash\";\n\t{body}\n}}\n" )); } + for suffix in crate::c::comparisons(traits.ord) { + let body = wrap(status, "i8", &format!("rt::{suffix}::<{path}>(&{lift_a}, &{lift_b})")); + self.export(format!( + "#[unsafe(no_mangle)]\npub unsafe extern \"C\" fn {name}_{suffix}(a: *const {c}, b: *const {c}{param}) -> i8 {{\n\tlet w = \"{name}_{suffix}\";\n\t{body}\n}}\n" + )); + } if traits.display { let body = wrap( status, diff --git a/ffi/src/go.rs b/ffi/src/go.rs index 46bff3d93..c9e4d0462 100644 --- a/ffi/src/go.rs +++ b/ffi/src/go.rs @@ -42,7 +42,7 @@ use std::collections::{BTreeMap, BTreeSet, HashMap}; use std::fmt::Write; use crate::abi::{self, Abi, Ty, pascal}; -use crate::ir::{Access, Closure, Collection, Function, Home, Int, Literal, On, Param, Receiver, Type}; +use crate::ir::{Access, Closure, Collection, Function, Home, Int, Literal, On, Order, Param, Receiver, Type}; const RUNTIME: &str = include_str!("../runtime/rt.go"); const CONVERSIONS: &str = include_str!("../runtime/ffi_cgo.go"); @@ -1846,6 +1846,65 @@ impl<'a> Gen<'a> { body, )); } + // Rust's `partial_cmp`, -1, 0, 1, or 2 when unordered, as `PartialCompare`, and with + // `Ord` its `cmp` as `Compare`, the shape `slices.SortFunc` takes. + for &suffix in crate::c::comparisons(t.ord) { + let (member, docs, zero, results, done) = match suffix { + "cmp" => ( + "Compare", + "Compare is Rust's Ord: -1, 0, or 1 as self is less than, equal to, or greater than other.", + "0", + vec!["int".to_string()], + "return int(r_)", + ), + _ => ( + "PartialCompare", + "PartialCompare is Rust's PartialOrd: -1, 0, or 1 as self is less than, equal to, or greater than\nother, and false when the two are unordered.", + "0, false", + vec!["int".to_string(), "bool".to_string()], + "if r_ == 2 {\n\treturn 0, false{ok}\n}\nreturn int(r_), true", + ), + }; + let failed = |e: &str| format!("{zero}, {e}"); + let (open, this) = match closable { + true => open(&failed), + false => open(&|_: &str| unreachable!("a value holding no object is never closed")), + }; + let (results, ok) = match closable || limited { + true => ([results, vec!["error".to_string()]].concat(), ", nil"), + false => (results, ""), + }; + let done = format!("{}{ok}", done.replace("{ok}", ok)); + let sig = || sig(suffix, 2, Ty::Int(Int::I8)); + let closed = format!("return {}", failed("other.Handle_.Closed()")); + let body = match (object, arena) { + (true, _) => format!( + "{open}{}\n{}{done}", + hold(&slot, "other", "o_", "os_", &closed), + checked(sig(), &[this, format!("(*C.{c})(o_)")], &failed) + ), + (false, true) if closable => format!( + "{open}c_other_ := lower_{c}(a_, other)\nif a_.err != nil {{\n\treturn {}\n}}\n{}{done}", + failed("a_.err"), + checked(sig(), &[this, "c_other_".to_string()], &failed) + ), + (false, true) => format!( + "{open}c_other_ := lower_{c}(a_, other)\n{}{done}", + checked(sig(), &[this, "c_other_".to_string()], &failed) + ), + (false, false) => format!( + "{open}c_other_ := lower_{c}(other)\n{}{done}", + checked(sig(), &[this, "c_other_".to_string()], &failed) + ), + }; + methods.push(method( + docs, + member, + vec![("other".to_string(), name.clone())], + results, + body, + )); + } let default = t.default.then(|| { let func = format!("{}Default", name.trim_start_matches('*')); // A value that is not `Send` is made on a home, which its calls then run on. @@ -1882,6 +1941,8 @@ impl<'a> Gen<'a> { "GoString" => ("debug", "err_.Error()".to_string()), "Clone" => ("clone", "nil, err_".to_string()), "Equal" => ("eq", "false, err_".to_string()), + "Compare" => ("cmp", "0, err_".to_string()), + "PartialCompare" => ("partial_cmp", "0, false, err_".to_string()), _ => ("default", format!("{zero}, err_")), }; method.body = format!( @@ -1962,6 +2023,8 @@ impl<'a> Gen<'a> { (t.display, "String"), (t.debug, "GoString"), (t.eq, "Equal"), + (t.ord != Order::None, "PartialCompare"), + (t.ord == Order::Total, "Compare"), (self.errored(&Type::Record(i)), "Error"), ]; let mut taken: BTreeSet = (methods.iter()) diff --git a/ffi/src/ir.rs b/ffi/src/ir.rs index 2376d9516..a1ea91105 100644 --- a/ffi/src/ir.rs +++ b/ffi/src/ir.rs @@ -417,6 +417,10 @@ pub(crate) struct Traits { /// A baseline written before it has none. #[serde(default)] pub(crate) hash: bool, + /// `PartialOrd` with itself, and whether it is a total order too, `Ord`. A baseline + /// written before it has none. + #[serde(default)] + pub(crate) ord: Order, pub(crate) display: bool, pub(crate) debug: bool, pub(crate) default: bool, @@ -433,6 +437,19 @@ pub(crate) struct Traits { pub(crate) leaf_sized: bool, } +/// How a type orders its values. +#[derive(Default, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug, serde::Serialize, serde::Deserialize)] +pub(crate) enum Order { + /// No `PartialOrd`. + #[default] + None, + /// `PartialOrd` alone: two values may be unordered, so a binding exports only the + /// partial comparison, never its language's total one. + Partial, + /// `Ord` as well, a total order agreeing with `PartialOrd`. + Total, +} + /// A function or method. #[derive(Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub(crate) struct Function { diff --git a/ffi/src/kotlin.rs b/ffi/src/kotlin.rs index edbedfd49..ac1402764 100644 --- a/ffi/src/kotlin.rs +++ b/ffi/src/kotlin.rs @@ -29,7 +29,7 @@ use std::hash::Hasher; use rustc_data_structures::stable_hash::StableHasher; use crate::abi::{self, Abi, Ty, pascal}; -use crate::ir::{Access, Family, Function, Int, Jni, Literal, Mutability, On, Opaque, Param, Receiver, Type}; +use crate::ir::{Access, Family, Function, Int, Jni, Literal, Mutability, On, Opaque, Order, Param, Receiver, Type}; const RUNTIME: &str = include_str!("../runtime/rt.kt"); /// The runtime's public types, at the generated file's top level. @@ -1633,6 +1633,52 @@ impl<'a> Gen<'a> { "\toverride fun equals(other: kotlin.Any?): kotlin.Boolean =\n\t\tother is {class} && handle.hold {{ a -> other.handle.hold {{ b -> _Native.{bare}_eq(a, b) }} }}\n\n{hash}" )); } + // Rust's `partial_cmp` as `partialCompareTo`, null when unordered, and with `Ord` its + // `cmp` as `Comparable`'s `compareTo`, except an enum class's, which Kotlin makes + // final by ordinal: of both handles, or of both values encoded. + let plain = matches!(ty, Type::Enum(i) if self.abi.api.enums[*i].plain()); + for &suffix in crate::c::comparisons(t.ord) { + let member = suffix == "cmp"; + if member && plain { + continue; + } + let (params, call, kt): (Vec<(&str, &str)>, _, _) = match object { + true => ( + vec![("jlong", "Long"); 2], + (String::new(), format!("crate::{c}_{suffix}(p0 as usize as _, p1 as usize as _)")), + format!("handle.hold {{ a -> other.handle.hold {{ b -> _Native.{bare}_{suffix}(a, b) }} }}"), + ), + false => ( + vec![("jbyteArray", "ByteArray"), ("jobjectArray", "kotlin.Array?")], + ( + "let b = rt::bytes(env, p0).unwrap_or_default();\n\t\tlet Some(mut r) = rt::Reader::new(env, &b, p1) else {\n\t\t\treturn rt::raised();\n\t\t};\n\t\tlet (x, y) = (r.get(), r.get());\n\t\t".to_string(), + format!("crate::{c}_{suffix}(&x, &y)"), + ), + format!( + "_Native.__Writer().use {{ w -> {}; {}; _Native.{bare}_{suffix}(w.finish(), w.refs()) }}", + self.write_value(ty, "w", "this"), + self.write_value(ty, "w", "other") + ), + ), + }; + let (pre, call) = call; + let rust = match status { + true => format!( + "{pre}let mut status = 0;\n\t\tlet ret = {}, &mut status);\n\t\tif status != 0 {{\n\t\t\treturn rt::refuse(env, status, \"{c}_{suffix}\");\n\t\t}}\n\t\tret as jint", + call.strip_suffix(')').expect("a call") + ), + false => format!("{pre}let ret = {call};\n\t\tret as jint"), + }; + self.native(&format!("{bare}_{suffix}"), ¶ms, ("jint", "Int"), &rust); + body.push(match member { + true => format!( + "\t/** Rust's `Ord`: -1, 0, or 1 as this is less than, equal to, or greater than `other`. */\n\toverride fun compareTo(other: {class}): kotlin.Int = {kt}\n" + ), + false => format!( + "\t/** Rust's `PartialOrd`: -1, 0, or 1 as this is less than, equal to, or greater than `other`, or null when the two are unordered. */\n\tfun partialCompareTo(other: {class}): kotlin.Int? = {kt}.takeIf {{ it != 2 }}\n" + ), + }); + } if t.default { let (jni, native, rust, lift) = match ty { Type::Object(_) => ( @@ -1721,15 +1767,16 @@ impl<'a> Gen<'a> { true => String::new(), false => format!(" {{\n{}}}", body.join("\n")), }; + let supers = comparable(record.traits.ord, &name, " : "); if let Some(opaque) = record.opaque { - self.opaque(&c, &name, &opaque, &docs, &body); + self.opaque(&c, &name, &opaque, &docs, &supers, &body); return; } match fields.is_empty() { true => { let _ = write!( self.types, - "{docs}class {name} {}\n\n", + "{docs}class {name}{supers} {}\n\n", match body.is_empty() { true => format!( "{{\n\toverride fun equals(other: kotlin.Any?): kotlin.Boolean = other is {name}\n\n\toverride fun hashCode(): kotlin.Int = 0\n}}" @@ -1752,7 +1799,7 @@ impl<'a> Gen<'a> { .collect(); let _ = write!( self.types, - "{docs}data class {name}(\n{}\n){body}\n\n", + "{docs}data class {name}(\n{}\n){supers}{body}\n\n", params.join("\n") ); } @@ -1791,7 +1838,7 @@ impl<'a> Gen<'a> { /// over the `Long` it fits in with no padding, or else a class of a `Long` for each of /// its words, which compares through Rust's `PartialEq`, so one that does not escape /// allocates nothing. Only Rust makes one. - fn opaque(&mut self, c: &str, name: &str, opaque: &Opaque, docs: &str, body: &str) { + fn opaque(&mut self, c: &str, name: &str, opaque: &Opaque, docs: &str, supers: &str, body: &str) { let words = opaque.words(); let holders = holders(opaque); // Set after a constructor of none, as a constructor of a parameter each would pass @@ -1815,7 +1862,7 @@ impl<'a> Gen<'a> { }; let write: String = holders.iter().map(|h| format!("\tw.i64(v.{h})\n")).collect(); let read = self.made(name, opaque, &vec!["r.i64()".to_string(); holders.len()]); - let _ = write!(self.types, "{docs}{head}{body}\n\n"); + let _ = write!(self.types, "{docs}{head}{supers}{body}\n\n"); let _ = write!( self.top, "internal fun w_{c}(w: _Native.__Writer, v: {name}) {{\n{write}}}\n\ninternal fun r_{c}(r: _Native.__Reader): {name} = {read}\n\n" @@ -2010,8 +2057,9 @@ impl<'a> Gen<'a> { all.extend(body); let _ = write!( self.types, - "{}sealed class {name} {{\n{}}}\n\n", + "{}sealed class {name}{} {{\n{}}}\n\n", docs(&e.docs, ""), + comparable(e.traits.ord, &name, " : "), all.join("\n") ); let _ = write!( @@ -2094,8 +2142,9 @@ impl<'a> Gen<'a> { let text = format!("{rust}\n\n{}", object.docs); let _ = write!( self.types, - "{}class {name} internal constructor(raw: Long, lent: Boolean = false) : AutoCloseable {{\n{}}}\n\n", + "{}class {name} internal constructor(raw: Long, lent: Boolean = false) : AutoCloseable{} {{\n{}}}\n\n", docs(text.trim(), ""), + comparable(object.traits.ord, &name, ", "), body.join("\n") ); } @@ -3698,6 +3747,14 @@ fn opaque_of(abi: &Abi<'_>, c: &Ty) -> Option { /// The properties of an opaque value's class holding it, a word each: a value class's /// `bits`, or `w0` and on. +/// The `Comparable` a class ordered by `ord` implements, after `sep`: only a total order is. +fn comparable(ord: Order, name: &str, sep: &str) -> String { + match ord { + Order::Total => format!("{sep}kotlin.Comparable<{name}>"), + _ => String::new(), + } +} + fn holders(opaque: &Opaque) -> Vec { match word(opaque) { true => vec!["bits".to_string()], diff --git a/ffi/src/lock.rs b/ffi/src/lock.rs index 79abc195b..827aae617 100644 --- a/ffi/src/lock.rs +++ b/ffi/src/lock.rs @@ -15,7 +15,7 @@ use std::collections::{BTreeMap, BTreeSet}; use rustc_span::{DUMMY_SP, Span}; use crate::abi::{Abi, Ty}; -use crate::ir::{Access, Api, Constant, Function, Literal, On, Opaque, Traits, Type}; +use crate::ir::{Access, Api, Constant, Function, Literal, On, Opaque, Order, Traits, Type}; use crate::merge::{self, Maps}; /// Each language's public names, keyed by the item's kind and Rust path. @@ -596,6 +596,8 @@ fn changed(base: &Index<'_>, now: &Index<'_>, maps: &Maps, ours: &Item<'_>, thei ("Clone", ours.clone && !theirs.clone), ("PartialEq", ours.eq && !theirs.eq), ("Hash", ours.hash && !theirs.hash), + ("PartialOrd", ours.ord != Order::None && theirs.ord == Order::None), + ("Ord", ours.ord == Order::Total && theirs.ord != Order::Total), ("Display", ours.display && !theirs.display), ("Debug", ours.debug && !theirs.debug), ("Default", ours.default && !theirs.default), diff --git a/ffi/src/python.rs b/ffi/src/python.rs index ccab638ff..a7b8079b6 100644 --- a/ffi/src/python.rs +++ b/ffi/src/python.rs @@ -27,7 +27,7 @@ use std::hash::Hasher; use rustc_data_structures::stable_hash::StableHasher; use crate::abi::{self, Abi, Ty, pascal}; -use crate::ir::{Access, Family, Function, Int, Literal, On, Param, Receiver, Traits, Type}; +use crate::ir::{Access, Family, Function, Int, Literal, On, Order, Param, Receiver, Traits, Type}; use crate::kotlin::{indent_by, rust_c, strip_refs}; const RUNTIME: &str = include_str!("../runtime/rt.py"); @@ -1197,6 +1197,44 @@ impl<'a> Gen<'a> { "@_staticmethod\ndef {bare}_eq(this: {class}, other: {class}, /) -> _bool: ...\n" )); } + // Every type orders through Rust's `partial_cmp`, as Rust's own `<` and its kin do: + // -1, 0, 1, or 2 when unordered, which none of them is. + if t.ord != Order::None { + let other = match object { + true => self.lift( + &Type::Ref(crate::ir::Mutability::Not, Box::new(ty.clone())), + "a[1]", + "false", + ), + false => self.lift(ty, "a[1]", "false"), + }; + let (a, b) = match object { + true => ("this", "other"), + false => ("&this", "&other"), + }; + let call = called(false, format!("crate::{c}_partial_cmp({a}, {b}{arg})")); + self.native( + &format!("{bare}_partial_cmp"), + 2, + &format!( + "let this = {this}?;\n\t\tlet other = {other}?;\n\t\t{status}let ret = {call};{}\n\t\ts.done();\n\t\trt::int_out(ret.into())", + check("partial_cmp") + ), + ); + for (dunder, test) in [ + ("__lt__", "== -1"), + ("__le__", "in (-1, 0)"), + ("__gt__", "== 1"), + ("__ge__", "in (0, 1)"), + ] { + body.python.push(format!( + "\tdef {dunder}(self, other: _object) -> _bool:\n\t\tif not _isinstance(other, {class}):\n\t\t\treturn _NotImplemented\n\t\treturn _n.{bare}_partial_cmp(self, other) {test}\n" + )); + } + self.natives.push(format!( + "@_staticmethod\ndef {bare}_partial_cmp(this: {class}, other: {class}, /) -> _int: ...\n" + )); + } // Rust's `Hash` makes it hashable again, agreeing with its `__eq__`. if (object || opaque) && t.hash { unary(self, "hash", "__hash__", "", "rt::uint_out(ret)".to_string()); diff --git a/ffi/src/swift.rs b/ffi/src/swift.rs index 952f7a2fb..b2679bd2c 100644 --- a/ffi/src/swift.rs +++ b/ffi/src/swift.rs @@ -26,7 +26,7 @@ use std::collections::{BTreeMap, BTreeSet, HashMap}; use std::fmt::Write; use crate::abi::{self, Abi, Ty, pascal}; -use crate::ir::{Access, Closure, Family, Function, Int, Literal, Mutability, On, Param, Receiver, Type}; +use crate::ir::{Access, Closure, Family, Function, Int, Literal, Mutability, On, Order, Param, Receiver, Type}; const RUNTIME: &str = include_str!("../runtime/rt.swift"); @@ -929,10 +929,40 @@ impl<'a> Gen<'a> { ), } }; + // The body calling `{c}_` of `a` and `b`, returning `lift` of its result. + let binary = |suffix: &str, lift: &dyn Fn(&str) -> String| { + let what = format!("{c}_{suffix}"); + match (object, unique) { + (true, true) => call(&format!("{what}(a.handle, b.handle"), &what, lift), + (true, false) => { + let with = |h: &str| match status { + true => format!("try {h}.handle.with(\"{what}\")"), + false => format!("{h}.handle.with"), + }; + format!( + "return {} {{ a_ in {} {{ b_ in\n\t\t\t{}\n\t\t}} }}", + with("a"), + with("b"), + call(&format!("{what}(a_, b_"), &what, lift).replace("\n\t\t", "\n\t\t\t") + ) + } + (false, _) => format!( + "{}var ca_ = {}\n\t\tvar cb_ = {}\n\t\t{}", + value(&what), + lower.replacen("self.", "a.", 1), + lower.replacen("self.", "b.", 1), + call(&format!("{what}(&ca_, &cb_"), &what, lift) + ), + } + }; let throws = match status { true => " throws", false => "", }; + let borrowing = match unique { + true => "borrowing ", + false => "", + }; // A property's body, in a getter that throws if the call can. let getter = |body: String| match status { true => format!("get throws {{\n\t\t\t{}\n\t\t}}", body.replace("\n\t\t", "\n\t\t\t")), @@ -975,38 +1005,39 @@ impl<'a> Gen<'a> { false => "Equatable", }); } - let what = format!("{c}_eq"); let same = |r: &str| r.to_string(); - let compare = match (object, unique) { - (true, true) => call(&format!("{what}(a.handle, b.handle"), &what, &same), - (true, false) => { - let with = |h: &str| match status { - true => format!("try {h}.handle.with(\"{what}\")"), - false => format!("{h}.handle.with"), - }; - format!( - "return {} {{ a_ in {} {{ b_ in\n\t\t\t{}\n\t\t}} }}", - with("a"), - with("b"), - call(&format!("{what}(a_, b_"), &what, &same).replace("\n\t\t", "\n\t\t\t") - ) - } - (false, _) => format!( - "{}var ca_ = {}\n\t\tvar cb_ = {}\n\t\t{}", - value(&what), - lower.replacen("self.", "a.", 1), - lower.replacen("self.", "b.", 1), - call(&format!("{what}(&ca_, &cb_"), &what, &same) - ), - }; - let borrowing = match unique { - true => "borrowing ", - false => "", - }; + let compare = binary("eq", &same); body.push(format!( "\tpublic static func == (a: {borrowing}{name}, b: {borrowing}{name}){throws} -> Swift.Bool {{\n\t\t{compare}\n\t}}\n" )); } + // `<` and its kin through Rust's `partial_cmp`, as Rust's are: -1, 0, 1, or 2 when + // unordered, which none of them is. A total order is `Comparable`, whose other + // operators these replace. + if t.ord != Order::None { + if t.ord == Order::Total && !status { + protocols.push("Comparable"); + } + let ordering = |r: &str| r.to_string(); + body.push(format!( + "\t/// Rust's `partial_cmp`: -1, 0, 1, or 2 when unordered.\n\tstatic func _partialCmp(_ a: {borrowing}{name}, _ b: {borrowing}{name}){throws} -> Swift.Int8 {{\n\t\t{}\n\t}}\n", + binary("partial_cmp", &ordering) + )); + let try_ = match status { + true => "try ", + false => "", + }; + for (op, test) in [ + ("<", "c_ == -1"), + ("<=", "c_ == -1 || c_ == 0"), + (">", "c_ == 1"), + (">=", "c_ == 0 || c_ == 1"), + ] { + body.push(format!( + "\tpublic static func {op} (a: {borrowing}{name}, b: {borrowing}{name}){throws} -> Swift.Bool {{\n\t\tlet c_ = {try_}_partialCmp(a, b)\n\t\treturn {test}\n\t}}\n" + )); + } + } if t.hash { members.push("hash(into:)".to_string()); let combine = |r: &str| format!("hasher.combine({r})"); diff --git a/ffi/src/web.rs b/ffi/src/web.rs index b4e70a535..50241293b 100644 --- a/ffi/src/web.rs +++ b/ffi/src/web.rs @@ -2318,6 +2318,36 @@ impl Gen<'_> { ); } } + // Rust's `partial_cmp`, -1, 0, 1, or 2 when unordered, as `partialCmp`, undefined when + // unordered, and with `Ord` its `cmp`, the shape `Array.prototype.sort` takes. A plain + // enum's too: its numbers order as its discriminants, which only a derived order follows. + for &suffix in crate::c::comparisons(t.ord) { + let mut lines = vec![this(self, "a", "a$"), this(self, "b", "b$")]; + let args = vec!["a$".to_string(), "b$".to_string()]; + let i8 = Ty::Int(Int::I8); + let ret = self.invoke(&format!("{c}_{suffix}"), args, &i8, status, &mut lines); + let value = self.result(&Type::Int(Int::I8), &ret); + let (member, doc, ret_t) = match suffix { + "cmp" => { + lines.push(format!("return {value};")); + ( + "cmp", + "Rust's `Ord`: -1, 0, or 1 as `a` is less than, equal to, or greater than `b`.", + "number", + ) + } + _ => { + lines.push(format!("const c$ = {value};")); + lines.push("return c$ === 2 ? undefined : c$;".to_string()); + ( + "partialCmp", + "Rust's `PartialOrd`: -1, 0, or 1 as `a` is less than, equal to, or greater than `b`, or undefined when the two are unordered.", + "number | undefined", + ) + } + }; + emit(self, member, doc, &format!("a: {name}, b: {name}"), ret_t, lines); + } if t.default { let ret_c = match object { true => Ty::Handle { diff --git a/ffi/surface/api/c.h b/ffi/surface/api/c.h index 3a97c236e..565c02aaa 100644 --- a/ffi/surface/api/c.h +++ b/ffi/surface/api/c.h @@ -7,7 +7,7 @@ #ifdef __cplusplus extern "C" { #endif -#define API_CONTRACT ((uint64_t)0xcadf3d448a865171ULL) +#define API_CONTRACT ((uint64_t)0x5dc92f21dacf6b64ULL) uint64_t api_contract(void); uint32_t api_target(void); typedef int32_t api_status; @@ -144,6 +144,7 @@ typedef struct api_Stack api_Stack; typedef struct api_Refusal api_Refusal; typedef struct api_Fault api_Fault; typedef struct api_c api_c; +typedef struct api_Quantity api_Quantity; typedef struct api_Key api_Key; typedef struct api_clash_Seed api_clash_Seed; typedef struct api_clash_Empty_string api_clash_Empty_string; @@ -178,6 +179,10 @@ typedef enum api_Family { typedef enum api_VecClashTone { API_VECCLASHTONE_ERROR = 0, } api_VecClashTone; +typedef enum api_Tier { + API_TIER_LOW = 0, + API_TIER_HIGH = 1, +} api_Tier; typedef enum api_Level { API_LEVEL_TRACE = 0, API_LEVEL_DEBUG = 1, @@ -810,6 +815,10 @@ typedef struct api_Qualifiers { double api; double kotlin; } api_Qualifiers; +typedef struct api_Version { + uint16_t major; + uint16_t minor; +} api_Version; typedef struct api_polar_Turn { uint8_t part; } api_polar_Turn; @@ -1284,6 +1293,11 @@ bool api_a_eq(const api_a *a, const api_a *b); api_buf api_a_debug(const api_a *self); void api_Qualifiers_free(api_Qualifiers *self); bool api_Qualifiers_eq(const api_Qualifiers *a, const api_Qualifiers *b); +void api_Version_free(api_Version *self); +bool api_Version_eq(const api_Version *a, const api_Version *b); +int8_t api_Version_partial_cmp(const api_Version *a, const api_Version *b); +int8_t api_Version_cmp(const api_Version *a, const api_Version *b); +api_buf api_Version_debug(const api_Version *self); void api_polar_Point_free(api_polar_Point *self); bool api_polar_Point_eq(const api_polar_Point *a, const api_polar_Point *b); api_buf api_polar_Point_debug(const api_polar_Point *self); @@ -1371,11 +1385,17 @@ bool api_b_eq(const api_b *a, const api_b *b); api_buf api_b_debug(const api_b *self); void api_Builtin_free(api_Builtin *self); bool api_Builtin_eq(const api_Builtin *a, const api_Builtin *b); +bool api_Tier_eq(const api_Tier *a, const api_Tier *b); +int8_t api_Tier_partial_cmp(const api_Tier *a, const api_Tier *b); +int8_t api_Tier_cmp(const api_Tier *a, const api_Tier *b); +api_buf api_Tier_debug(const api_Tier *self); void api_clash_Candidate_free(api_clash_Candidate *self); bool api_clash_Candidate_eq(const api_clash_Candidate *a, const api_clash_Candidate *b); api_buf api_clash_Candidate_debug(const api_clash_Candidate *self); bool api_Level_eq(const api_Level *a, const api_Level *b); uint64_t api_Level_hash(const api_Level *self); +int8_t api_Level_partial_cmp(const api_Level *a, const api_Level *b); +int8_t api_Level_cmp(const api_Level *a, const api_Level *b); api_buf api_Level_to_string(const api_Level *self); void api_Board_free(api_Board *self); void api_Board_drop(api_Board *self, api_status *status); @@ -1841,6 +1861,11 @@ void api_c_free(api_c *self); bool api_c_eq(const api_c *a, const api_c *b); api_buf api_c_debug(const api_c *self); api_c *api_c_new(uint8_t value); +void api_Quantity_free(api_Quantity *self); +bool api_Quantity_eq(const api_Quantity *a, const api_Quantity *b); +int8_t api_Quantity_partial_cmp(const api_Quantity *a, const api_Quantity *b); +api_buf api_Quantity_debug(const api_Quantity *self); +api_Quantity *api_Quantity_new(int64_t value, uint32_t unit); void api_Key_free(api_Key *self); bool api_Key_borrowed(const api_Key *self); api_Key *api_Key_clone(const api_Key *self); @@ -1869,6 +1894,8 @@ bool api_Url_borrowed(const api_Url *self); api_Url *api_Url_clone(const api_Url *self, api_status *status); bool api_Url_eq(const api_Url *a, const api_Url *b, api_status *status); uint64_t api_Url_hash(const api_Url *self, api_status *status); +int8_t api_Url_partial_cmp(const api_Url *a, const api_Url *b, api_status *status); +int8_t api_Url_cmp(const api_Url *a, const api_Url *b, api_status *status); api_buf api_Url_to_string(const api_Url *self, api_status *status); api_buf api_Url_debug(const api_Url *self, api_status *status); bool api_Url_parse(api_buf input, api_Url **out, api_buf *err); @@ -1881,6 +1908,8 @@ bool api_Instant_borrowed(const api_Instant *self); api_Instant *api_Instant_clone(const api_Instant *self); bool api_Instant_eq(const api_Instant *a, const api_Instant *b); uint64_t api_Instant_hash(const api_Instant *self); +int8_t api_Instant_partial_cmp(const api_Instant *a, const api_Instant *b); +int8_t api_Instant_cmp(const api_Instant *a, const api_Instant *b); api_buf api_Instant_debug(const api_Instant *self); void api_std_io_Error_free(api_std_io_Error *self); void api_std_io_Error_drop(api_std_io_Error *self, api_status *status); diff --git a/ffi/surface/api/cpp.hpp b/ffi/surface/api/cpp.hpp index 0ff640344..1edecd059 100644 --- a/ffi/surface/api/cpp.hpp +++ b/ffi/surface/api/cpp.hpp @@ -25,6 +25,10 @@ namespace api { enum class VecClashTone { error = 0, }; + enum class Tier { + low = 0, + high = 1, + }; inline constexpr ::std::uint64_t LIMIT = API_LIMIT; inline constexpr ::std::int64_t FAR = API_FAR; class RUST2_FFI_CONSUMABLE Board { @@ -538,6 +542,21 @@ namespace api { RUST2_FFI_CALLABLE ::api::buf debug() const; static ::api::c new_(::std::uint8_t value); }; + class RUST2_FFI_CONSUMABLE Quantity { + RUST2_FFI_UNCONSUMED Quantity(Quantity &&other RUST2_FFI_MOVED_FROM) noexcept = default; + Quantity &operator=(Quantity &&other) noexcept = default; + friend bool operator==(const Quantity &a__, const Quantity &b_); + friend bool operator!=(const Quantity &a__, const Quantity &b_); + friend bool operator<(const Quantity &a__, const Quantity &b_); + friend bool operator<=(const Quantity &a__, const Quantity &b_); + friend bool operator>(const Quantity &a__, const Quantity &b_); + friend bool operator>=(const Quantity &a__, const Quantity &b_); + #if defined(__cpp_lib_three_way_comparison) + friend ::std::partial_ordering operator<=>(const Quantity &a__, const Quantity &b_); + #endif + RUST2_FFI_CALLABLE ::api::buf debug() const; + static ::api::Quantity new_(::std::int64_t value, char32_t unit); + }; class RUST2_FFI_CONSUMABLE Key { RUST2_FFI_UNCONSUMED Key(Key &&other RUST2_FFI_MOVED_FROM) noexcept = default; Key &operator=(Key &&other) noexcept = default; @@ -1039,6 +1058,20 @@ namespace api { friend bool operator==(const Qualifiers &a__, const Qualifiers &b_); friend bool operator!=(const Qualifiers &a__, const Qualifiers &b_); }; + struct Version { + ::std::uint16_t major; + ::std::uint16_t minor; + friend bool operator==(const Version &a__, const Version &b_); + friend bool operator!=(const Version &a__, const Version &b_); + friend bool operator<(const Version &a__, const Version &b_); + friend bool operator<=(const Version &a__, const Version &b_); + friend bool operator>(const Version &a__, const Version &b_); + friend bool operator>=(const Version &a__, const Version &b_); + #if defined(__cpp_lib_three_way_comparison) + friend ::std::weak_ordering operator<=>(const Version &a__, const Version &b_); + #endif + ::api::buf debug() const; + }; struct polar_Point { ::std::uint8_t turns; ::std::uint32_t distance; @@ -1249,6 +1282,14 @@ namespace api { inline bool operator==(const DoubleArray &a__, const DoubleArray &b_); inline bool operator==(const a &a__, const a &b_); inline bool operator==(const Qualifiers &a__, const Qualifiers &b_); + inline bool operator==(const Version &a__, const Version &b_); + inline bool operator<(const Version &a__, const Version &b_); + inline bool operator<=(const Version &a__, const Version &b_); + inline bool operator>(const Version &a__, const Version &b_); + inline bool operator>=(const Version &a__, const Version &b_); + #if defined(__cpp_lib_three_way_comparison) + inline ::std::weak_ordering operator<=>(const Version &a__, const Version &b_); + #endif inline bool operator==(const polar_Point &a__, const polar_Point &b_); inline bool operator==(const polar_Turn &a__, const polar_Turn &b_); inline bool operator==(const clash_Tone &a__, const clash_Tone &b_); @@ -1304,6 +1345,16 @@ namespace api { inline ::api::buf b_debug(const ::api::b &self); inline bool operator==(const ::api::Builtin &a__, const ::api::Builtin &b_); inline bool operator!=(const ::api::Builtin &a__, const ::api::Builtin &b_); + inline bool operator==(::api::Tier a__, ::api::Tier b_); + inline bool operator!=(::api::Tier a__, ::api::Tier b_); + inline bool operator<(::api::Tier a__, ::api::Tier b_); + inline bool operator<=(::api::Tier a__, ::api::Tier b_); + inline bool operator>(::api::Tier a__, ::api::Tier b_); + inline bool operator>=(::api::Tier a__, ::api::Tier b_); + #if defined(__cpp_lib_three_way_comparison) + inline ::std::weak_ordering operator<=>(::api::Tier a__, ::api::Tier b_); + #endif + inline ::api::buf Tier_debug(::api::Tier self); inline bool operator==(const ::api::clash_Candidate &a__, const ::api::clash_Candidate &b_); inline bool operator!=(const ::api::clash_Candidate &a__, const ::api::clash_Candidate &b_); inline ::api::buf clash_Candidate_debug(const ::api::clash_Candidate &self); @@ -1675,6 +1726,9 @@ namespace api { #if defined(__cpp_impl_coroutine) && __cpp_impl_coroutine >= 201902L && __has_include() #include #endif +#if defined(__cpp_impl_three_way_comparison) && __cpp_impl_three_way_comparison >= 201907L && __has_include() +#include +#endif namespace api { #if defined(__clang__) #define RUST2_FFI_LIFETIMEBOUND [[clang::lifetimebound]] @@ -1826,6 +1880,7 @@ namespace api { enum class Status_; enum class Family; enum class VecClashTone; + enum class Tier; enum class Level; struct Parcel; struct Weighted; @@ -1883,6 +1938,7 @@ namespace api { struct NonZeros; struct a; struct Qualifiers; + struct Version; struct polar_Point; struct polar_Turn; struct clash_Tone; @@ -1947,6 +2003,7 @@ namespace api { class Refusal; class Fault; class c; + class Quantity; class Key; class clash_Seed; class clash_Empty_string; @@ -2088,6 +2145,13 @@ namespace api { Instant &operator=(const Instant &other) = default; friend bool operator==(const Instant &a__, const Instant &b_); friend bool operator!=(const Instant &a__, const Instant &b_); + friend bool operator<(const Instant &a__, const Instant &b_); + friend bool operator<=(const Instant &a__, const Instant &b_); + friend bool operator>(const Instant &a__, const Instant &b_); + friend bool operator>=(const Instant &a__, const Instant &b_); + #if defined(__cpp_lib_three_way_comparison) + friend ::std::weak_ordering operator<=>(const Instant &a__, const Instant &b_); + #endif RUST2_FFI_CALLABLE ::std::uint64_t hash() const; RUST2_FFI_CALLABLE ::api::buf debug() const; }; @@ -2154,6 +2218,13 @@ namespace api { }; inline bool operator==(::api::Level a__, ::api::Level b_); inline bool operator!=(::api::Level a__, ::api::Level b_); + inline bool operator<(::api::Level a__, ::api::Level b_); + inline bool operator<=(::api::Level a__, ::api::Level b_); + inline bool operator>(::api::Level a__, ::api::Level b_); + inline bool operator>=(::api::Level a__, ::api::Level b_); + #if defined(__cpp_lib_three_way_comparison) + inline ::std::weak_ordering operator<=>(::api::Level a__, ::api::Level b_); + #endif inline ::api::buf Level_to_string(::api::Level self); } #endif @@ -2170,6 +2241,13 @@ namespace api { Url &operator=(const Url &other) = default; friend bool operator==(const Url &a__, const Url &b_); friend bool operator!=(const Url &a__, const Url &b_); + friend bool operator<(const Url &a__, const Url &b_); + friend bool operator<=(const Url &a__, const Url &b_); + friend bool operator>(const Url &a__, const Url &b_); + friend bool operator>=(const Url &a__, const Url &b_); + #if defined(__cpp_lib_three_way_comparison) + friend ::std::weak_ordering operator<=>(const Url &a__, const Url &b_); + #endif RUST2_FFI_CALLABLE ::std::uint64_t hash() const; RUST2_FFI_CALLABLE ::api::buf to_string() const; RUST2_FFI_CALLABLE ::api::buf debug() const; diff --git a/ffi/surface/api/dart.dart b/ffi/surface/api/dart.dart index 8e2f112ab..56c22c6eb 100644 --- a/ffi/surface/api/dart.dart +++ b/ffi/surface/api/dart.dart @@ -607,6 +607,20 @@ final class Qualifiers { @override bool operator ==(Object other); @override int get hashCode; } +final class Version implements Comparable { + final int major; + final int minor; + const Version({required this.major, required this.minor}); + String debug(); + @override bool operator ==(Object other); + @override int get hashCode; + int? partialCompareTo(Version other); + bool operator <(Version other); + bool operator <=(Version other); + bool operator >(Version other); + bool operator >=(Version other); + @override int compareTo(Version other); +} final class PolarPoint { final int turns; final int distance; @@ -915,6 +929,18 @@ final class BuiltinNative extends Builtin { final double $0; const BuiltinNative(this.$0); } +enum Tier implements Comparable { + low(0), + high(1), + const Tier(this._c); + String debug(); + int? partialCompareTo(Tier other); + bool operator <(Tier other); + bool operator <=(Tier other); + bool operator >(Tier other); + bool operator >=(Tier other); + @override int compareTo(Tier other); +} sealed class ClashCandidate { const ClashCandidate(); String debug(); @@ -928,7 +954,7 @@ final class ClashCandidateMatch extends ClashCandidate { final int $0; const ClashCandidateMatch(this.$0); } -enum Level { +enum Level implements Comparable { trace(0), debug(1), info(2), @@ -936,6 +962,12 @@ enum Level { error(4), const Level(this._c); @override String toString(); + int? partialCompareTo(Level other); + bool operator <(Level other); + bool operator <=(Level other); + bool operator >(Level other); + bool operator >=(Level other); + @override int compareTo(Level other); } final class Board extends _Object { factory Board(List<(String, Counter)> counters); @@ -1342,6 +1374,17 @@ final class C extends _Object { @override int get hashCode; factory C(int value); } +final class Quantity extends _Object { + String debug(); + @override bool operator ==(Object other); + @override int get hashCode; + int? partialCompareTo(Quantity other); + bool operator <(Quantity other); + bool operator <=(Quantity other); + bool operator >(Quantity other); + bool operator >=(Quantity other); + factory Quantity(int value, String unit); +} final class Key extends _Object { String debug(); Key clone(); @@ -1368,23 +1411,35 @@ final class TlsSession extends _Object { String alpn(); TlsPolicyLifetime lifetime(); } -final class Url extends _Object { +final class Url extends _Object implements Comparable { @override String toString(); String debug(); Url clone(); @override bool operator ==(Object other); @override int get hashCode; + int? partialCompareTo(Url other); + bool operator <(Url other); + bool operator <=(Url other); + bool operator >(Url other); + bool operator >=(Url other); + @override int compareTo(Url other); factory Url.parse(String input); } final class Json extends _Object { factory Json.parse(String input); String toText(); } -final class Instant extends _Object { +final class Instant extends _Object implements Comparable { String debug(); Instant clone(); @override bool operator ==(Object other); @override int get hashCode; + int? partialCompareTo(Instant other); + bool operator <(Instant other); + bool operator <=(Instant other); + bool operator >(Instant other); + bool operator >=(Instant other); + @override int compareTo(Instant other); } final class StdIoError extends _Object { } diff --git a/ffi/surface/api/go.txt b/ffi/surface/api/go.txt index b05f13558..af6213ce3 100644 --- a/ffi/surface/api/go.txt +++ b/ffi/surface/api/go.txt @@ -1370,6 +1370,14 @@ type Qualifiers struct { Kotlin float64 } func (self Qualifiers) Equal(other Qualifiers) bool +type Quantity struct { + Handle_ *p_rt.Handle_ +} +func NewQuantity(value int64, unit rune) (*Quantity, error) +func (self *Quantity) Close() error +func (self *Quantity) Equal(other *Quantity) (bool, error) +func (self *Quantity) GoString() string +func (self *Quantity) PartialCompare(other *Quantity) (int, bool, error) type Reading struct { Ok bool Level float32 @@ -1613,6 +1621,15 @@ func ReissueLent(ticket Ticket, swap func(Ticket) Ticket) Ticket func (self Ticket) Equal(other Ticket) bool func (self Ticket) GoString() string func (self Ticket) Number() uint32 +type Tier int32 +const ( + TierLow Tier = 0 + TierHigh Tier = 1 +) +func (self Tier) Compare(other Tier) int +func (self Tier) Equal(other Tier) bool +func (self Tier) GoString() string +func (self Tier) PartialCompare(other Tier) (int, bool) type Token struct { Handle_ *p_rt.Handle_ } @@ -1652,6 +1669,14 @@ func (self *Verbosity) Close() error func (self *Verbosity) Filter() (*p_tracingcore.Level, error) func (self *Verbosity) LevelGet() (p_tracingcore.Level, error) func (self *Verbosity) LevelSet(value p_tracingcore.Level) error +type Version struct { + Major uint16 + Minor uint16 +} +func (self Version) Compare(other Version) int +func (self Version) Equal(other Version) bool +func (self Version) GoString() string +func (self Version) PartialCompare(other Version) (int, bool) type Waiter struct { Handle_ *p_rt.Handle_ } @@ -1882,8 +1907,10 @@ type Instant struct { } func (self *Instant) Clone() (*Instant, error) func (self *Instant) Close() error +func (self *Instant) Compare(other *Instant) (int, error) func (self *Instant) Equal(other *Instant) (bool, error) func (self *Instant) GoString() string +func (self *Instant) PartialCompare(other *Instant) (int, bool, error) package tls // import "api/tls" @@ -1929,7 +1956,9 @@ const ( LevelWarn Level = 3 LevelError Level = 4 ) +func (self Level) Compare(other Level) int func (self Level) Equal(other Level) bool +func (self Level) PartialCompare(other Level) (int, bool) func (self Level) String() string package url // import "api/url" @@ -1941,7 +1970,9 @@ type Url struct { func UrlParse(input string) (*Url, error) func (self *Url) Clone() (*Url, error) func (self *Url) Close() error +func (self *Url) Compare(other *Url) (int, error) func (self *Url) Equal(other *Url) (bool, error) func (self *Url) GoString() string +func (self *Url) PartialCompare(other *Url) (int, bool, error) func (self *Url) String() string diff --git a/ffi/surface/api/kotlin.kt b/ffi/surface/api/kotlin.kt index e55948964..7dcc004cb 100644 --- a/ffi/surface/api/kotlin.kt +++ b/ffi/surface/api/kotlin.kt @@ -359,6 +359,11 @@ data class Qualifiers(val api: kotlin.Double, val kotlin: kotlin.Double) { override fun equals(other: kotlin.Any?): kotlin.Boolean override fun hashCode(): kotlin.Int } +data class Version(val major: kotlin.UShort, val minor: kotlin.UShort) : kotlin.Comparable { + fun debug(): kotlin.String + fun partialCompareTo(other: api.Version): kotlin.Int? + override fun compareTo(other: api.Version): kotlin.Int +} data class PolarPoint(val turns: kotlin.UByte, val distance: kotlin.UInt) { fun debug(): kotlin.String } @@ -518,6 +523,13 @@ sealed class Builtin { override fun hashCode(): kotlin.Int } } +enum class Tier(internal val value: Int) { + LOW(0), + HIGH(1); + fun debug(): kotlin.String + fun partialCompareTo(other: api.Tier): kotlin.Int? + companion object {} +} sealed class ClashCandidate { data object None : ClashCandidate() data class Match(val _0: kotlin.UByte) : ClashCandidate() @@ -530,6 +542,7 @@ enum class Level(internal val value: Int) { WARN(3), ERROR(4); final override fun toString(): kotlin.String + fun partialCompareTo(other: api.Level): kotlin.Int? companion object {} } class Board internal constructor(raw: Long, lent: Boolean = false) : AutoCloseable { @@ -1089,6 +1102,16 @@ class C internal constructor(raw: Long, lent: Boolean = false) : AutoCloseable { @kotlin.jvm.JvmStatic fun new(value: kotlin.UByte): api.C } } +class Quantity internal constructor(raw: Long, lent: Boolean = false) : AutoCloseable { + override fun close() + fun debug(): kotlin.String + override fun equals(other: kotlin.Any?): kotlin.Boolean + override fun hashCode(): kotlin.Int + fun partialCompareTo(other: api.Quantity): kotlin.Int? + companion object { + @kotlin.jvm.JvmStatic fun new(value: kotlin.Long, unit: kotlin.Int): api.Quantity + } +} class Key internal constructor(raw: Long, lent: Boolean = false) : AutoCloseable { override fun close() fun debug(): kotlin.String @@ -1126,13 +1149,15 @@ class TlsSession internal constructor(raw: Long, lent: Boolean = false) : AutoCl fun alpn(): kotlin.String fun lifetime(): api.TlsPolicyLifetime } -class Url internal constructor(raw: Long, lent: Boolean = false) : AutoCloseable { +class Url internal constructor(raw: Long, lent: Boolean = false) : AutoCloseable, kotlin.Comparable { override fun close() final override fun toString(): kotlin.String fun debug(): kotlin.String fun clone(): api.Url override fun equals(other: kotlin.Any?): kotlin.Boolean override fun hashCode(): kotlin.Int + fun partialCompareTo(other: api.Url): kotlin.Int? + override fun compareTo(other: api.Url): kotlin.Int companion object { @kotlin.jvm.JvmStatic @kotlin.jvm.Throws(StringException::class) fun parse(input: kotlin.String): api.Url } @@ -1144,12 +1169,14 @@ class Json internal constructor(raw: Long, lent: Boolean = false) : AutoCloseabl @kotlin.jvm.JvmStatic @kotlin.jvm.Throws(StringException::class) fun parse(input: kotlin.String): api.Json } } -class Instant internal constructor(raw: Long, lent: Boolean = false) : AutoCloseable { +class Instant internal constructor(raw: Long, lent: Boolean = false) : AutoCloseable, kotlin.Comparable { override fun close() fun debug(): kotlin.String fun clone(): api.Instant override fun equals(other: kotlin.Any?): kotlin.Boolean override fun hashCode(): kotlin.Int + fun partialCompareTo(other: api.Instant): kotlin.Int? + override fun compareTo(other: api.Instant): kotlin.Int } class StdIoError internal constructor(raw: Long, lent: Boolean = false) : AutoCloseable { override fun close() diff --git a/ffi/surface/api/python.pyi b/ffi/surface/api/python.pyi index 5bffaac98..ebbc5e176 100644 --- a/ffi/surface/api/python.pyi +++ b/ffi/surface/api/python.pyi @@ -418,6 +418,16 @@ class Qualifiers(_Record): kotlin: _float def __init__(self, api: _float, kotlin: _float) -> None: ... def __eq__(self, other: _object) -> _bool: ... +class Version(_Record): + major: _int + minor: _int + def __init__(self, major: _int, minor: _int) -> None: ... + def __eq__(self, other: _object) -> _bool: ... + def __lt__(self, other: _object) -> _bool: ... + def __le__(self, other: _object) -> _bool: ... + def __gt__(self, other: _object) -> _bool: ... + def __ge__(self, other: _object) -> _bool: ... + def __repr__(self) -> _str: ... class PolarPoint(_Record): turns: _int distance: _int @@ -699,6 +709,14 @@ class _Builtin_Native(Builtin, _Record): _0: _float def __init__(self, _0: _float) -> None: ... def __eq__(self, other: _object) -> _bool: ... +class Tier(_enum.Enum): + LOW = 0 + HIGH = 1 + def __lt__(self, other: _object) -> _bool: ... + def __le__(self, other: _object) -> _bool: ... + def __gt__(self, other: _object) -> _bool: ... + def __ge__(self, other: _object) -> _bool: ... + def __repr__(self) -> _str: ... class ClashCandidate: def __repr__(self) -> _str: ... None_: _typing.TypeAlias = '_ClashCandidate_None_' @@ -715,6 +733,10 @@ class Level(_enum.Enum): INFO = 2 WARN = 3 ERROR = 4 + def __lt__(self, other: _object) -> _bool: ... + def __le__(self, other: _object) -> _bool: ... + def __gt__(self, other: _object) -> _bool: ... + def __ge__(self, other: _object) -> _bool: ... def __str__(self) -> _str: ... class Board(_n.Object): @_staticmethod @@ -1149,6 +1171,15 @@ class C(_n.Object): def __repr__(self) -> _str: ... @_staticmethod def new(value: _int) -> C: ... +class Quantity(_n.Object): + def __eq__(self, other: _object) -> _bool: ... + def __lt__(self, other: _object) -> _bool: ... + def __le__(self, other: _object) -> _bool: ... + def __gt__(self, other: _object) -> _bool: ... + def __ge__(self, other: _object) -> _bool: ... + def __repr__(self) -> _str: ... + @_staticmethod + def new(value: _int, unit: _str) -> Quantity: ... class Key(_n.Object): def __eq__(self, other: _object) -> _bool: ... def __repr__(self) -> _str: ... @@ -1176,6 +1207,10 @@ class TlsSession(_n.Object): def lifetime(self) -> TlsPolicyLifetime: ... class Url(_n.Object): def __eq__(self, other: _object) -> _bool: ... + def __lt__(self, other: _object) -> _bool: ... + def __le__(self, other: _object) -> _bool: ... + def __gt__(self, other: _object) -> _bool: ... + def __ge__(self, other: _object) -> _bool: ... def __str__(self) -> _str: ... def __repr__(self) -> _str: ... def clone(self) -> Url: ... @@ -1188,6 +1223,10 @@ class Json(_n.Object): def to_text(self) -> _str: ... class Instant(_n.Object): def __eq__(self, other: _object) -> _bool: ... + def __lt__(self, other: _object) -> _bool: ... + def __le__(self, other: _object) -> _bool: ... + def __gt__(self, other: _object) -> _bool: ... + def __ge__(self, other: _object) -> _bool: ... def __repr__(self) -> _str: ... def clone(self) -> Instant: ... def __hash__(self) -> _int: ... diff --git a/ffi/surface/api/swift.swift b/ffi/surface/api/swift.swift index 6bad3ed5c..0ab55bd45 100644 --- a/ffi/surface/api/swift.swift +++ b/ffi/surface/api/swift.swift @@ -572,6 +572,17 @@ public struct Qualifiers: Sendable, Equatable { @inlinable public init(api: Swift.Double, kotlin: Swift.Double) @inlinable public static func == (a: Qualifiers, b: Qualifiers) -> Swift.Bool } +public struct Version: Sendable, CustomDebugStringConvertible, Equatable, Comparable { + public var major: Swift.UInt16 + public var minor: Swift.UInt16 + @inlinable public init(major: Swift.UInt16, minor: Swift.UInt16) + @inlinable public var debugDescription: Swift.String { get } + @inlinable public static func == (a: Version, b: Version) -> Swift.Bool + @inlinable public static func < (a: Version, b: Version) -> Swift.Bool + @inlinable public static func <= (a: Version, b: Version) -> Swift.Bool + @inlinable public static func > (a: Version, b: Version) -> Swift.Bool + @inlinable public static func >= (a: Version, b: Version) -> Swift.Bool +} public struct PolarPoint: Sendable, CustomDebugStringConvertible, Equatable { public var turns: Swift.UInt8 public var distance: Swift.UInt32 @@ -744,13 +755,23 @@ public enum Builtin: Sendable, Equatable { case native(Swift.Double) @inlinable public static func == (a: Builtin, b: Builtin) -> Swift.Bool } +public enum Tier: Sendable, CustomDebugStringConvertible, Equatable, Comparable { + case low + case high + @inlinable public var debugDescription: Swift.String { get } + @inlinable public static func == (a: Tier, b: Tier) -> Swift.Bool + @inlinable public static func < (a: Tier, b: Tier) -> Swift.Bool + @inlinable public static func <= (a: Tier, b: Tier) -> Swift.Bool + @inlinable public static func > (a: Tier, b: Tier) -> Swift.Bool + @inlinable public static func >= (a: Tier, b: Tier) -> Swift.Bool +} public enum ClashCandidate: Sendable, CustomDebugStringConvertible, Equatable { case none case match(Swift.UInt8) @inlinable public var debugDescription: Swift.String { get } @inlinable public static func == (a: ClashCandidate, b: ClashCandidate) -> Swift.Bool } -public enum Level: Sendable, CustomStringConvertible, Hashable { +public enum Level: Sendable, CustomStringConvertible, Hashable, Comparable { case trace case debug case info @@ -758,6 +779,10 @@ public enum Level: Sendable, CustomStringConvertible, Hashable { case error @inlinable public var description: Swift.String { get } @inlinable public static func == (a: Level, b: Level) -> Swift.Bool + @inlinable public static func < (a: Level, b: Level) -> Swift.Bool + @inlinable public static func <= (a: Level, b: Level) -> Swift.Bool + @inlinable public static func > (a: Level, b: Level) -> Swift.Bool + @inlinable public static func >= (a: Level, b: Level) -> Swift.Bool @inlinable public func hash(into hasher: inout Swift.Hasher) } public struct Board: ~Copyable, @unchecked Sendable { @@ -1171,6 +1196,18 @@ public struct C: ~Copyable, @unchecked Sendable { #if compiler(>=6.4) extension C: Equatable {} #endif +public struct Quantity: ~Copyable, @unchecked Sendable { + @inlinable public var debugDescription: Swift.String { get } + @inlinable public static func == (a: borrowing Quantity, b: borrowing Quantity) -> Swift.Bool + @inlinable public static func < (a: borrowing Quantity, b: borrowing Quantity) -> Swift.Bool + @inlinable public static func <= (a: borrowing Quantity, b: borrowing Quantity) -> Swift.Bool + @inlinable public static func > (a: borrowing Quantity, b: borrowing Quantity) -> Swift.Bool + @inlinable public static func >= (a: borrowing Quantity, b: borrowing Quantity) -> Swift.Bool + @inlinable public static func new(_ value: Swift.Int64, _ unit: Swift.Unicode.Scalar) -> Quantity +} +#if compiler(>=6.4) +extension Quantity: Equatable {} +#endif public struct Key: ~Copyable, @unchecked Sendable { @inlinable public var debugDescription: Swift.String { get } @inlinable public func clone() -> Key @@ -1205,6 +1242,10 @@ public struct Url: ~Copyable, @unchecked Sendable { @inlinable public var debugDescription: Swift.String { get } @inlinable public func clone() throws -> Url @inlinable public static func == (a: borrowing Url, b: borrowing Url) throws -> Swift.Bool + @inlinable public static func < (a: borrowing Url, b: borrowing Url) throws -> Swift.Bool + @inlinable public static func <= (a: borrowing Url, b: borrowing Url) throws -> Swift.Bool + @inlinable public static func > (a: borrowing Url, b: borrowing Url) throws -> Swift.Bool + @inlinable public static func >= (a: borrowing Url, b: borrowing Url) throws -> Swift.Bool @inlinable public func hash(into hasher: inout Swift.Hasher) throws @inlinable public static func parse(_ input: Swift.String) throws -> Url } @@ -1212,10 +1253,14 @@ public struct Json: ~Copyable, @unchecked Sendable { @inlinable public static func parse(_ input: Swift.String) throws -> Json @inlinable public func toText() throws -> Swift.String } -public final class Instant: @unchecked Sendable, CustomDebugStringConvertible, Hashable { +public final class Instant: @unchecked Sendable, CustomDebugStringConvertible, Hashable, Comparable { @inlinable public var debugDescription: Swift.String { get } @inlinable public func clone() -> Instant @inlinable public static func == (a: Instant, b: Instant) -> Swift.Bool + @inlinable public static func < (a: Instant, b: Instant) -> Swift.Bool + @inlinable public static func <= (a: Instant, b: Instant) -> Swift.Bool + @inlinable public static func > (a: Instant, b: Instant) -> Swift.Bool + @inlinable public static func >= (a: Instant, b: Instant) -> Swift.Bool @inlinable public func hash(into hasher: inout Swift.Hasher) } public struct StdIoError: ~Copyable, @unchecked Sendable {} diff --git a/ffi/surface/api/web.d.ts b/ffi/surface/api/web.d.ts index 0b1317501..e2c367499 100644 --- a/ffi/surface/api/web.d.ts +++ b/ffi/surface/api/web.d.ts @@ -531,6 +531,8 @@ export declare function debug(self: Instant): string; export declare function clone(self: Instant): Instant; export declare function eq(a: Instant, b: Instant): boolean; export declare function hash(self: Instant): rt.u64; +export declare function partialCmp(a: Instant, b: Instant): number | undefined; +export declare function cmp(a: Instant, b: Instant): number; // Journal.ts import * as rt from "./rt.ts"; @@ -657,6 +659,8 @@ export declare function eq(a: LeftU8, b: LeftU8): boolean; // Level.ts export type Level = "Trace" | "Debug" | "Info" | "Warn" | "Error"; export declare function toString(self: Level): string; +export declare function partialCmp(a: Level, b: Level): number | undefined; +export declare function cmp(a: Level, b: Level): number; // LimitsBytes.ts export type LimitsBytes = { @@ -1064,6 +1068,15 @@ export type Qualifiers = { }; export declare function eq(a: Qualifiers, b: Qualifiers): boolean; +// Quantity.ts +import * as rt from "./rt.ts"; +export type Quantity = rt.Handle<"Quantity">; +export declare function debug(self: Quantity): string; +export declare function eq(a: Quantity, b: Quantity): boolean; +export declare function partialCmp(a: Quantity, b: Quantity): number | undefined; +export declare function new$(value: rt.i64, unit: number): Quantity; +export { new$ as new }; + // Reading.ts import * as rt from "./rt.ts"; import type { Point } from "./Point.ts"; @@ -1343,6 +1356,12 @@ export declare function number(self: Ticket): number; export declare function clones(): number; export { new$ as new }; +// Tier.ts +export type Tier = "Low" | "High"; +export declare function debug(self: Tier): string; +export declare function partialCmp(a: Tier, b: Tier): number | undefined; +export declare function cmp(a: Tier, b: Tier): number; + // TlsCert.ts import * as rt from "./rt.ts"; export type TlsCert = rt.Handle<"TlsCert">; @@ -1408,6 +1427,8 @@ export declare function debug(self: Url): string; export declare function clone(self: Url): Url; export declare function eq(a: Url, b: Url): boolean; export declare function hash(self: Url): rt.u64; +export declare function partialCmp(a: Url, b: Url): number | undefined; +export declare function cmp(a: Url, b: Url): number; export declare function parse(input: string): rt.Result; // VecClashTone.ts @@ -1424,6 +1445,16 @@ export declare function new$(level: Level): Verbosity; export declare function filter(self: Verbosity): Level | undefined; export { new$ as new }; +// Version.ts +export type Version = { + major: number; + minor: number; +}; +export declare function debug(self: Version): string; +export declare function eq(a: Version, b: Version): boolean; +export declare function partialCmp(a: Version, b: Version): number | undefined; +export declare function cmp(a: Version, b: Version): number; + // Waiter.ts import * as rt from "./rt.ts"; export type Waiter = rt.Handle<"Waiter">; @@ -1569,11 +1600,13 @@ import type { StartSeekable } from "./StartSeekable.ts"; import type { Status } from "./Status.ts"; import type { Tally } from "./Tally.ts"; import type { Ticket } from "./Ticket.ts"; +import type { Tier } from "./Tier.ts"; import type { TlsCert } from "./TlsCert.ts"; import type { TlsCodec } from "./TlsCodec.ts"; import type { TlsPolicyLifetime } from "./TlsPolicyLifetime.ts"; import type { Token } from "./Token.ts"; import type { VecClashTone } from "./VecClashTone.ts"; +import type { Version } from "./Version.ts"; import type { Waiter } from "./Waiter.ts"; import type { Weighted } from "./Weighted.ts"; import type { Wide } from "./Wide.ts"; @@ -1583,6 +1616,7 @@ export declare function e_Family(v: Family): number; export declare function e_Level(v: Level): number; export declare function e_Shape(v: Shape): number; export declare function e_Status_(v: Status): number; +export declare function e_Tier(v: Tier): number; export declare function e_VecClashTone(v: VecClashTone): number; export declare function f0(): number; export declare function f1(): number; @@ -1641,6 +1675,7 @@ export declare const k_Outer_Inner_u8: rt.Kind; export declare const k_Pad_u16: rt.Kind; export declare const k_Pad_u8: rt.Kind; export declare const k_Plain: rt.Kind; +export declare const k_Quantity: rt.Kind; export declare const k_Receipt: rt.Kind; export declare const k_Refusal: rt.Kind; export declare const k_Registry: rt.Kind; @@ -1930,6 +1965,7 @@ export declare function w_Stamp(p: number, v: Stamp): void; export declare function w_Stamped(p: number, v: Stamped): void; export declare function w_StartSeekable(p: number, v: StartSeekable): void; export declare function w_Ticket(p: number, v: Ticket): void; +export declare function w_Version(p: number, v: Version): void; export declare function w_Weighted(p: number, v: Weighted): void; export declare function w_Wide(p: number, v: Wide): void; export declare function w_Window(p: number, v: Window): void; diff --git a/ffi/surface/moq-web/web.d.ts b/ffi/surface/moq-web/web.d.ts index e7855956d..de4cdc805 100644 --- a/ffi/surface/moq-web/web.d.ts +++ b/ffi/surface/moq-web/web.d.ts @@ -200,6 +200,8 @@ export type BandwidthRate = rt.Opaque<"BandwidthRate">; export declare function debug(self: BandwidthRate): string; export declare function eq(a: BandwidthRate, b: BandwidthRate): boolean; export declare function hash(self: BandwidthRate): rt.u64; +export declare function partialCmp(a: BandwidthRate, b: BandwidthRate): number | undefined; +export declare function cmp(a: BandwidthRate, b: BandwidthRate): number; export declare function default$(): BandwidthRate; export declare function ZERO(): BandwidthRate; export declare function fromBps(bps: rt.u64): BandwidthRate; @@ -526,6 +528,8 @@ export type ClockInstant = rt.Opaque<"ClockInstant">; export declare function debug(self: ClockInstant): string; export declare function eq(a: ClockInstant, b: ClockInstant): boolean; export declare function hash(self: ClockInstant): rt.u64; +export declare function partialCmp(a: ClockInstant, b: ClockInstant): number | undefined; +export declare function cmp(a: ClockInstant, b: ClockInstant): number; export declare function ZERO(): ClockInstant; export declare function now(): ClockInstant; export declare function elapsed(self: ClockInstant): rt.Duration; @@ -580,6 +584,8 @@ export type ClockWall = rt.Opaque<"ClockWall">; export declare function debug(self: ClockWall): string; export declare function eq(a: ClockWall, b: ClockWall): boolean; export declare function hash(self: ClockWall): rt.u64; +export declare function partialCmp(a: ClockWall, b: ClockWall): number | undefined; +export declare function cmp(a: ClockWall, b: ClockWall): number; export declare function UNIX_EPOCH(): ClockWall; export declare function MOQ_EPOCH(): ClockWall; export declare function now(): ClockWall; @@ -874,6 +880,8 @@ export type GroupInfo = { export declare function debug(self: GroupInfo): string; export declare function eq(a: GroupInfo, b: GroupInfo): boolean; export declare function hash(self: GroupInfo): rt.u64; +export declare function partialCmp(a: GroupInfo, b: GroupInfo): number | undefined; +export declare function cmp(a: GroupInfo, b: GroupInfo): number; // GroupProducer.ts import * as rt from "./rt.ts"; @@ -1914,6 +1922,8 @@ export declare function debug(self: Instance): string; export declare function clone(self: Instance): Instance; export declare function eq(a: Instance, b: Instance): boolean; export declare function hash(self: Instance): rt.u64; +export declare function partialCmp(a: Instance, b: Instance): number | undefined; +export declare function cmp(a: Instance, b: Instance): number; export declare function random(): Instance; export declare function asStr(self: Instance): string; export declare function isMinted(self: Instance): boolean; @@ -1925,6 +1935,8 @@ export declare function debug(self: Instant): string; export declare function clone(self: Instant): Instant; export declare function eq(a: Instant, b: Instant): boolean; export declare function hash(self: Instant): rt.u64; +export declare function partialCmp(a: Instant, b: Instant): number | undefined; +export declare function cmp(a: Instant, b: Instant): number; // IntersectionError.ts export type IntersectionError = "TooManyPatterns"; @@ -7572,6 +7584,8 @@ import * as rt from "./rt.ts"; export type OriginCost = rt.Opaque<"OriginCost">; export declare function debug(self: OriginCost): string; export declare function eq(a: OriginCost, b: OriginCost): boolean; +export declare function partialCmp(a: OriginCost, b: OriginCost): number | undefined; +export declare function cmp(a: OriginCost, b: OriginCost): number; export declare function default$(): OriginCost; export declare function new$(cost: rt.u64): OriginCost; export declare function value(self: OriginCost): rt.u64; @@ -7604,6 +7618,8 @@ export type OriginPriority = rt.Opaque<"OriginPriority">; export declare function debug(self: OriginPriority): string; export declare function eq(a: OriginPriority, b: OriginPriority): boolean; export declare function hash(self: OriginPriority): rt.u64; +export declare function partialCmp(a: OriginPriority, b: OriginPriority): number | undefined; +export declare function cmp(a: OriginPriority, b: OriginPriority): number; export declare function default$(): OriginPriority; export declare function new$(priority: number): OriginPriority; export declare function value(self: OriginPriority): number; @@ -7753,6 +7769,8 @@ export declare function debug(self: Path): string; export declare function clone(self: Path): Path; export declare function eq(a: Path, b: Path): boolean; export declare function hash(self: Path): rt.u64; +export declare function partialCmp(a: Path, b: Path): number | undefined; +export declare function cmp(a: Path, b: Path): number; export declare function default$(): Path; export declare function new$(s: string): rt.Result; export declare function fromStatic(s: string): Path; @@ -7804,6 +7822,8 @@ export declare function debug(self: Pattern): string; export declare function clone(self: Pattern): Pattern; export declare function eq(a: Pattern, b: Pattern): boolean; export declare function hash(self: Pattern): rt.u64; +export declare function partialCmp(a: Pattern, b: Pattern): number | undefined; +export declare function cmp(a: Pattern, b: Pattern): number; export declare function default$(): Pattern; export declare function new$(segments: Segment[]): rt.Result; export declare function all(): Pattern; @@ -8161,6 +8181,8 @@ export declare function debug(self: Specificity): string; export declare function clone(self: Specificity): Specificity; export declare function eq(a: Specificity, b: Specificity): boolean; export declare function hash(self: Specificity): rt.u64; +export declare function partialCmp(a: Specificity, b: Specificity): number | undefined; +export declare function cmp(a: Specificity, b: Specificity): number; // StatsActivity.ts import * as rt from "./rt.ts"; @@ -8706,6 +8728,8 @@ export declare function toString(self: Timescale): string; export declare function debug(self: Timescale): string; export declare function eq(a: Timescale, b: Timescale): boolean; export declare function hash(self: Timescale): rt.u64; +export declare function partialCmp(a: Timescale, b: Timescale): number | undefined; +export declare function cmp(a: Timescale, b: Timescale): number; export declare function SECOND(): Timescale; export declare function MILLI(): Timescale; export declare function MICRO(): Timescale; @@ -8723,6 +8747,7 @@ export declare function debug(self: Timestamp): string; export declare function clone(self: Timestamp): Timestamp; export declare function eq(a: Timestamp, b: Timestamp): boolean; export declare function hash(self: Timestamp): rt.u64; +export declare function partialCmp(a: Timestamp, b: Timestamp): number | undefined; export declare function ZERO(): Timestamp; export declare function new$(value: rt.u64, scale: Timescale): rt.Result; export declare function unscaled(key: rt.u64): Timestamp; @@ -8766,6 +8791,8 @@ export type TrackAnchor = { export declare function debug(self: TrackAnchor): string; export declare function eq(a: TrackAnchor, b: TrackAnchor): boolean; export declare function hash(self: TrackAnchor): rt.u64; +export declare function partialCmp(a: TrackAnchor, b: TrackAnchor): number | undefined; +export declare function cmp(a: TrackAnchor, b: TrackAnchor): number; // TrackCompression.ts export type TrackCompression = "None" | "Deflate"; @@ -8928,6 +8955,8 @@ export type TrackPosition = rt.Opaque<"TrackPosition">; export declare function debug(self: TrackPosition): string; export declare function eq(a: TrackPosition, b: TrackPosition): boolean; export declare function hash(self: TrackPosition): rt.u64; +export declare function partialCmp(a: TrackPosition, b: TrackPosition): number | undefined; +export declare function cmp(a: TrackPosition, b: TrackPosition): number; export declare function default$(): TrackPosition; export declare function groupGet(self: TrackPosition): rt.u64; export declare function groupSet(self: TrackPosition, value: rt.u64): TrackPosition; @@ -8994,6 +9023,8 @@ export type TrackRange = { export declare function debug(self: TrackRange): string; export declare function eq(a: TrackRange, b: TrackRange): boolean; export declare function hash(self: TrackRange): rt.u64; +export declare function partialCmp(a: TrackRange, b: TrackRange): number | undefined; +export declare function cmp(a: TrackRange, b: TrackRange): number; export declare function live(): TrackRange; export declare function oldest(): TrackRange; @@ -9256,6 +9287,8 @@ export declare function debug(self: Url): string; export declare function clone(self: Url): Url; export declare function eq(a: Url, b: Url): boolean; export declare function hash(self: Url): rt.u64; +export declare function partialCmp(a: Url, b: Url): number | undefined; +export declare function cmp(a: Url, b: Url): number; export declare function parse(input: string): rt.Result; // Version.ts diff --git a/ffi/surface/moq/c.h b/ffi/surface/moq/c.h index 3120435e1..ee9af9d55 100644 --- a/ffi/surface/moq/c.h +++ b/ffi/surface/moq/c.h @@ -7,7 +7,7 @@ #ifdef __cplusplus extern "C" { #endif -#define MOQ_CONTRACT ((uint64_t)0x4e64edc3aadb27fcULL) +#define MOQ_CONTRACT ((uint64_t)0xabfd8e4774ebabf6ULL) uint64_t moq_contract(void); uint32_t moq_target(void); typedef int32_t moq_status; @@ -2324,6 +2324,8 @@ moq_buf moq_TimeOverflow_to_string(const moq_TimeOverflow *self); moq_buf moq_TimeOverflow_debug(const moq_TimeOverflow *self); bool moq_Timescale_eq(const moq_Timescale *a, const moq_Timescale *b); uint64_t moq_Timescale_hash(const moq_Timescale *self); +int8_t moq_Timescale_partial_cmp(const moq_Timescale *a, const moq_Timescale *b); +int8_t moq_Timescale_cmp(const moq_Timescale *a, const moq_Timescale *b); moq_buf moq_Timescale_to_string(const moq_Timescale *self); moq_buf moq_Timescale_debug(const moq_Timescale *self); moq_Timescale moq_Timescale_SECOND(void); @@ -2334,6 +2336,8 @@ bool moq_Timescale_new(uint64_t units_per_second, moq_Timescale *out, moq_TimeOv uint64_t moq_Timescale_as_u64(const moq_Timescale *self); bool moq_clock_Instant_eq(const moq_clock_Instant *a, const moq_clock_Instant *b); uint64_t moq_clock_Instant_hash(const moq_clock_Instant *self); +int8_t moq_clock_Instant_partial_cmp(const moq_clock_Instant *a, const moq_clock_Instant *b); +int8_t moq_clock_Instant_cmp(const moq_clock_Instant *a, const moq_clock_Instant *b); moq_buf moq_clock_Instant_debug(const moq_clock_Instant *self); moq_clock_Instant moq_clock_Instant_ZERO(void); moq_clock_Instant moq_clock_Instant_now(void); @@ -2352,6 +2356,8 @@ moq_buf moq_clock_Elapsed_to_string(const moq_clock_Elapsed *self); moq_buf moq_clock_Elapsed_debug(const moq_clock_Elapsed *self); bool moq_clock_Wall_eq(const moq_clock_Wall *a, const moq_clock_Wall *b); uint64_t moq_clock_Wall_hash(const moq_clock_Wall *self); +int8_t moq_clock_Wall_partial_cmp(const moq_clock_Wall *a, const moq_clock_Wall *b); +int8_t moq_clock_Wall_cmp(const moq_clock_Wall *a, const moq_clock_Wall *b); moq_buf moq_clock_Wall_debug(const moq_clock_Wall *self); moq_clock_Wall moq_clock_Wall_UNIX_EPOCH(void); moq_clock_Wall moq_clock_Wall_MOQ_EPOCH(void); @@ -2558,6 +2564,8 @@ void moq_stats_Withdrawals_add(moq_stats_Withdrawals *self, moq_stats_Withdrawal bool moq_stats_Withdrawals_regressed(const moq_stats_Withdrawals *self, moq_stats_Withdrawals previous); bool moq_bandwidth_Rate_eq(const moq_bandwidth_Rate *a, const moq_bandwidth_Rate *b); uint64_t moq_bandwidth_Rate_hash(const moq_bandwidth_Rate *self); +int8_t moq_bandwidth_Rate_partial_cmp(const moq_bandwidth_Rate *a, const moq_bandwidth_Rate *b); +int8_t moq_bandwidth_Rate_cmp(const moq_bandwidth_Rate *a, const moq_bandwidth_Rate *b); moq_buf moq_bandwidth_Rate_debug(const moq_bandwidth_Rate *self); moq_bandwidth_Rate moq_bandwidth_Rate_default(void); moq_bandwidth_Rate moq_bandwidth_Rate_ZERO(void); @@ -2575,6 +2583,8 @@ moq_buf moq_frame_Info_debug(const moq_frame_Info *self, moq_status *status); void moq_group_Info_free(moq_group_Info *self); bool moq_group_Info_eq(const moq_group_Info *a, const moq_group_Info *b); uint64_t moq_group_Info_hash(const moq_group_Info *self); +int8_t moq_group_Info_partial_cmp(const moq_group_Info *a, const moq_group_Info *b); +int8_t moq_group_Info_cmp(const moq_group_Info *a, const moq_group_Info *b); moq_buf moq_group_Info_debug(const moq_group_Info *self); void moq_track_Delay_free(moq_track_Delay *self); bool moq_track_Delay_eq(const moq_track_Delay *a, const moq_track_Delay *b); @@ -2584,6 +2594,8 @@ moq_track_Delay moq_track_Delay_with_min(const moq_track_Delay *self, moq_option moq_track_Delay moq_track_Delay_with_max(const moq_track_Delay *self, moq_option_duration max); bool moq_track_Position_eq(const moq_track_Position *a, const moq_track_Position *b); uint64_t moq_track_Position_hash(const moq_track_Position *self); +int8_t moq_track_Position_partial_cmp(const moq_track_Position *a, const moq_track_Position *b); +int8_t moq_track_Position_cmp(const moq_track_Position *a, const moq_track_Position *b); moq_buf moq_track_Position_debug(const moq_track_Position *self); moq_track_Position moq_track_Position_default(void); uint64_t moq_track_Position_group_get(const moq_track_Position *self); @@ -2595,16 +2607,22 @@ moq_track_Position moq_track_Position_group(uint64_t group); void moq_track_Range_free(moq_track_Range *self); bool moq_track_Range_eq(const moq_track_Range *a, const moq_track_Range *b); uint64_t moq_track_Range_hash(const moq_track_Range *self); +int8_t moq_track_Range_partial_cmp(const moq_track_Range *a, const moq_track_Range *b); +int8_t moq_track_Range_cmp(const moq_track_Range *a, const moq_track_Range *b); moq_buf moq_track_Range_debug(const moq_track_Range *self); moq_track_Range moq_track_Range_live(void); moq_track_Range moq_track_Range_oldest(void); bool moq_origin_Cost_eq(const moq_origin_Cost *a, const moq_origin_Cost *b); +int8_t moq_origin_Cost_partial_cmp(const moq_origin_Cost *a, const moq_origin_Cost *b); +int8_t moq_origin_Cost_cmp(const moq_origin_Cost *a, const moq_origin_Cost *b); moq_buf moq_origin_Cost_debug(const moq_origin_Cost *self); moq_origin_Cost moq_origin_Cost_default(void); moq_origin_Cost moq_origin_Cost_new(uint64_t cost); uint64_t moq_origin_Cost_value(const moq_origin_Cost *self); bool moq_origin_Priority_eq(const moq_origin_Priority *a, const moq_origin_Priority *b); uint64_t moq_origin_Priority_hash(const moq_origin_Priority *self); +int8_t moq_origin_Priority_partial_cmp(const moq_origin_Priority *a, const moq_origin_Priority *b); +int8_t moq_origin_Priority_cmp(const moq_origin_Priority *a, const moq_origin_Priority *b); moq_buf moq_origin_Priority_debug(const moq_origin_Priority *self); moq_origin_Priority moq_origin_Priority_default(void); moq_origin_Priority moq_origin_Priority_new(int8_t priority); @@ -2814,6 +2832,8 @@ moq_track_Compression moq_track_Compression_default(void); void moq_track_Anchor_free(moq_track_Anchor *self); bool moq_track_Anchor_eq(const moq_track_Anchor *a, const moq_track_Anchor *b); uint64_t moq_track_Anchor_hash(const moq_track_Anchor *self); +int8_t moq_track_Anchor_partial_cmp(const moq_track_Anchor *a, const moq_track_Anchor *b); +int8_t moq_track_Anchor_cmp(const moq_track_Anchor *a, const moq_track_Anchor *b); moq_buf moq_track_Anchor_debug(const moq_track_Anchor *self); bool moq_track_Order_eq(const moq_track_Order *a, const moq_track_Order *b); uint64_t moq_track_Order_hash(const moq_track_Order *self); @@ -2993,6 +3013,8 @@ moq_buf moq_moq_sock_udp_EcnCodepoint_debug(const moq_moq_sock_udp_EcnCodepoint moq_option_moq_sock_udp_EcnCodepoint moq_moq_sock_udp_EcnCodepoint_from_bits(uint8_t x); bool moq_Level_eq(const moq_Level *a, const moq_Level *b); uint64_t moq_Level_hash(const moq_Level *self); +int8_t moq_Level_partial_cmp(const moq_Level *a, const moq_Level *b); +int8_t moq_Level_cmp(const moq_Level *a, const moq_Level *b); moq_buf moq_Level_to_string(const moq_Level *self); void moq_Park_free(moq_Park *self); void moq_Park_drop(moq_Park *self, moq_status *status); @@ -3039,6 +3061,8 @@ bool moq_Instance_borrowed(const moq_Instance *self); moq_Instance *moq_Instance_clone(const moq_Instance *self, moq_status *status); bool moq_Instance_eq(const moq_Instance *a, const moq_Instance *b, moq_status *status); uint64_t moq_Instance_hash(const moq_Instance *self, moq_status *status); +int8_t moq_Instance_partial_cmp(const moq_Instance *a, const moq_Instance *b, moq_status *status); +int8_t moq_Instance_cmp(const moq_Instance *a, const moq_Instance *b, moq_status *status); moq_buf moq_Instance_to_string(const moq_Instance *self, moq_status *status); moq_buf moq_Instance_debug(const moq_Instance *self, moq_status *status); moq_Instance *moq_Instance_random(void); @@ -3050,6 +3074,8 @@ bool moq_Path_borrowed(const moq_Path *self); moq_Path *moq_Path_clone(const moq_Path *self, moq_status *status); bool moq_Path_eq(const moq_Path *a, const moq_Path *b, moq_status *status); uint64_t moq_Path_hash(const moq_Path *self, moq_status *status); +int8_t moq_Path_partial_cmp(const moq_Path *a, const moq_Path *b, moq_status *status); +int8_t moq_Path_cmp(const moq_Path *a, const moq_Path *b, moq_status *status); moq_buf moq_Path_to_string(const moq_Path *self, moq_status *status); moq_buf moq_Path_debug(const moq_Path *self, moq_status *status); moq_Path *moq_Path_default(void); @@ -3072,6 +3098,8 @@ bool moq_Pattern_borrowed(const moq_Pattern *self); moq_Pattern *moq_Pattern_clone(const moq_Pattern *self, moq_status *status); bool moq_Pattern_eq(const moq_Pattern *a, const moq_Pattern *b, moq_status *status); uint64_t moq_Pattern_hash(const moq_Pattern *self, moq_status *status); +int8_t moq_Pattern_partial_cmp(const moq_Pattern *a, const moq_Pattern *b, moq_status *status); +int8_t moq_Pattern_cmp(const moq_Pattern *a, const moq_Pattern *b, moq_status *status); moq_buf moq_Pattern_to_string(const moq_Pattern *self, moq_status *status); moq_buf moq_Pattern_debug(const moq_Pattern *self, moq_status *status); moq_Pattern *moq_Pattern_default(void); @@ -3225,6 +3253,7 @@ bool moq_Timestamp_borrowed(const moq_Timestamp *self); moq_Timestamp *moq_Timestamp_clone(const moq_Timestamp *self, moq_status *status); bool moq_Timestamp_eq(const moq_Timestamp *a, const moq_Timestamp *b, moq_status *status); uint64_t moq_Timestamp_hash(const moq_Timestamp *self, moq_status *status); +int8_t moq_Timestamp_partial_cmp(const moq_Timestamp *a, const moq_Timestamp *b, moq_status *status); moq_buf moq_Timestamp_debug(const moq_Timestamp *self, moq_status *status); moq_Timestamp *moq_Timestamp_ZERO(void); bool moq_Timestamp_new(uint64_t value, moq_Timescale scale, moq_Timestamp **out, moq_TimeOverflow *err); @@ -3274,6 +3303,8 @@ bool moq_Specificity_borrowed(const moq_Specificity *self); moq_Specificity *moq_Specificity_clone(const moq_Specificity *self); bool moq_Specificity_eq(const moq_Specificity *a, const moq_Specificity *b); uint64_t moq_Specificity_hash(const moq_Specificity *self); +int8_t moq_Specificity_partial_cmp(const moq_Specificity *a, const moq_Specificity *b); +int8_t moq_Specificity_cmp(const moq_Specificity *a, const moq_Specificity *b); moq_buf moq_Specificity_debug(const moq_Specificity *self); void moq_clock_Clock_free(moq_clock_Clock *self); bool moq_clock_Clock_borrowed(const moq_clock_Clock *self); @@ -3557,6 +3588,8 @@ bool moq_tokio_Duration_borrowed(const moq_tokio_Duration *self); moq_tokio_Duration *moq_tokio_Duration_clone(const moq_tokio_Duration *self); bool moq_tokio_Duration_eq(const moq_tokio_Duration *a, const moq_tokio_Duration *b); uint64_t moq_tokio_Duration_hash(const moq_tokio_Duration *self); +int8_t moq_tokio_Duration_partial_cmp(const moq_tokio_Duration *a, const moq_tokio_Duration *b); +int8_t moq_tokio_Duration_cmp(const moq_tokio_Duration *a, const moq_tokio_Duration *b); moq_buf moq_tokio_Duration_to_string(const moq_tokio_Duration *self); moq_buf moq_tokio_Duration_debug(const moq_tokio_Duration *self); moq_tokio_Duration *moq_tokio_Duration_default(void); @@ -9249,6 +9282,8 @@ bool moq_Url_borrowed(const moq_Url *self); moq_Url *moq_Url_clone(const moq_Url *self, moq_status *status); bool moq_Url_eq(const moq_Url *a, const moq_Url *b, moq_status *status); uint64_t moq_Url_hash(const moq_Url *self, moq_status *status); +int8_t moq_Url_partial_cmp(const moq_Url *a, const moq_Url *b, moq_status *status); +int8_t moq_Url_cmp(const moq_Url *a, const moq_Url *b, moq_status *status); moq_buf moq_Url_to_string(const moq_Url *self, moq_status *status); moq_buf moq_Url_debug(const moq_Url *self, moq_status *status); bool moq_Url_parse(moq_buf input, moq_Url **out, moq_buf *err); @@ -9261,6 +9296,8 @@ bool moq_Instant_borrowed(const moq_Instant *self); moq_Instant *moq_Instant_clone(const moq_Instant *self); bool moq_Instant_eq(const moq_Instant *a, const moq_Instant *b); uint64_t moq_Instant_hash(const moq_Instant *self); +int8_t moq_Instant_partial_cmp(const moq_Instant *a, const moq_Instant *b); +int8_t moq_Instant_cmp(const moq_Instant *a, const moq_Instant *b); moq_buf moq_Instant_debug(const moq_Instant *self); void moq_rustls_ServerConfig_free(moq_rustls_ServerConfig *self); bool moq_rustls_ServerConfig_borrowed(const moq_rustls_ServerConfig *self); diff --git a/ffi/surface/moq/cpp.hpp b/ffi/surface/moq/cpp.hpp index c3c26a97e..d781def79 100644 --- a/ffi/surface/moq/cpp.hpp +++ b/ffi/surface/moq/cpp.hpp @@ -1000,6 +1000,13 @@ namespace moq { class clock_Instant { friend bool operator==(const clock_Instant &a, const clock_Instant &b); friend bool operator!=(const clock_Instant &a, const clock_Instant &b); + friend bool operator<(const clock_Instant &a, const clock_Instant &b); + friend bool operator<=(const clock_Instant &a, const clock_Instant &b); + friend bool operator>(const clock_Instant &a, const clock_Instant &b); + friend bool operator>=(const clock_Instant &a, const clock_Instant &b); + #if defined(__cpp_lib_three_way_comparison) + friend ::std::weak_ordering operator<=>(const clock_Instant &a, const clock_Instant &b); + #endif ::moq::buf debug() const; static ::moq::clock_Instant ZERO(); static ::moq::clock_Instant now(); @@ -1023,6 +1030,13 @@ namespace moq { class clock_Wall { friend bool operator==(const clock_Wall &a, const clock_Wall &b); friend bool operator!=(const clock_Wall &a, const clock_Wall &b); + friend bool operator<(const clock_Wall &a, const clock_Wall &b); + friend bool operator<=(const clock_Wall &a, const clock_Wall &b); + friend bool operator>(const clock_Wall &a, const clock_Wall &b); + friend bool operator>=(const clock_Wall &a, const clock_Wall &b); + #if defined(__cpp_lib_three_way_comparison) + friend ::std::weak_ordering operator<=>(const clock_Wall &a, const clock_Wall &b); + #endif ::moq::buf debug() const; static ::moq::clock_Wall UNIX_EPOCH(); static ::moq::clock_Wall MOQ_EPOCH(); @@ -1034,8 +1048,22 @@ namespace moq { ::std::optional<::moq::clock_Wall> checked_sub(::moq::duration duration_) const; }; inline bool operator==(const clock_Instant &a, const clock_Instant &b); + inline bool operator<(const clock_Instant &a, const clock_Instant &b); + inline bool operator<=(const clock_Instant &a, const clock_Instant &b); + inline bool operator>(const clock_Instant &a, const clock_Instant &b); + inline bool operator>=(const clock_Instant &a, const clock_Instant &b); + #if defined(__cpp_lib_three_way_comparison) + inline ::std::weak_ordering operator<=>(const clock_Instant &a, const clock_Instant &b); + #endif inline bool operator==(const clock_Elapsed &a, const clock_Elapsed &b); inline bool operator==(const clock_Wall &a, const clock_Wall &b); + inline bool operator<(const clock_Wall &a, const clock_Wall &b); + inline bool operator<=(const clock_Wall &a, const clock_Wall &b); + inline bool operator>(const clock_Wall &a, const clock_Wall &b); + inline bool operator>=(const clock_Wall &a, const clock_Wall &b); + #if defined(__cpp_lib_three_way_comparison) + inline ::std::weak_ordering operator<=>(const clock_Wall &a, const clock_Wall &b); + #endif inline bool operator==(::moq::clock_MissedTickBehavior a, ::moq::clock_MissedTickBehavior b); inline bool operator!=(::moq::clock_MissedTickBehavior a, ::moq::clock_MissedTickBehavior b); inline ::moq::buf clock_MissedTickBehavior_debug(::moq::clock_MissedTickBehavior self); @@ -5197,6 +5225,13 @@ namespace moq { Instance &operator=(const Instance &other) = default; friend bool operator==(const Instance &a, const Instance &b); friend bool operator!=(const Instance &a, const Instance &b); + friend bool operator<(const Instance &a, const Instance &b); + friend bool operator<=(const Instance &a, const Instance &b); + friend bool operator>(const Instance &a, const Instance &b); + friend bool operator>=(const Instance &a, const Instance &b); + #if defined(__cpp_lib_three_way_comparison) + friend ::std::weak_ordering operator<=>(const Instance &a, const Instance &b); + #endif RUST2_FFI_CALLABLE ::std::uint64_t hash() const; RUST2_FFI_CALLABLE ::moq::buf to_string() const; RUST2_FFI_CALLABLE ::moq::buf debug() const; @@ -5211,6 +5246,13 @@ namespace moq { Path &operator=(const Path &other) = default; friend bool operator==(const Path &a, const Path &b); friend bool operator!=(const Path &a, const Path &b); + friend bool operator<(const Path &a, const Path &b); + friend bool operator<=(const Path &a, const Path &b); + friend bool operator>(const Path &a, const Path &b); + friend bool operator>=(const Path &a, const Path &b); + #if defined(__cpp_lib_three_way_comparison) + friend ::std::weak_ordering operator<=>(const Path &a, const Path &b); + #endif RUST2_FFI_CALLABLE ::std::uint64_t hash() const; RUST2_FFI_CALLABLE ::moq::buf to_string() const; RUST2_FFI_CALLABLE ::moq::buf debug() const; @@ -5316,6 +5358,13 @@ namespace moq { Timestamp &operator=(const Timestamp &other) = default; friend bool operator==(const Timestamp &a, const Timestamp &b); friend bool operator!=(const Timestamp &a, const Timestamp &b); + friend bool operator<(const Timestamp &a, const Timestamp &b); + friend bool operator<=(const Timestamp &a, const Timestamp &b); + friend bool operator>(const Timestamp &a, const Timestamp &b); + friend bool operator>=(const Timestamp &a, const Timestamp &b); + #if defined(__cpp_lib_three_way_comparison) + friend ::std::partial_ordering operator<=>(const Timestamp &a, const Timestamp &b); + #endif RUST2_FFI_CALLABLE ::std::uint64_t hash() const; RUST2_FFI_CALLABLE ::moq::buf debug() const; static ::moq::Timestamp ZERO(); @@ -6601,6 +6650,13 @@ namespace moq { class Timescale { friend bool operator==(const Timescale &a, const Timescale &b); friend bool operator!=(const Timescale &a, const Timescale &b); + friend bool operator<(const Timescale &a, const Timescale &b); + friend bool operator<=(const Timescale &a, const Timescale &b); + friend bool operator>(const Timescale &a, const Timescale &b); + friend bool operator>=(const Timescale &a, const Timescale &b); + #if defined(__cpp_lib_three_way_comparison) + friend ::std::weak_ordering operator<=>(const Timescale &a, const Timescale &b); + #endif ::moq::buf to_string() const; ::moq::buf debug() const; static ::moq::Timescale SECOND(); @@ -6848,6 +6904,13 @@ namespace moq { class bandwidth_Rate { friend bool operator==(const bandwidth_Rate &a, const bandwidth_Rate &b); friend bool operator!=(const bandwidth_Rate &a, const bandwidth_Rate &b); + friend bool operator<(const bandwidth_Rate &a, const bandwidth_Rate &b); + friend bool operator<=(const bandwidth_Rate &a, const bandwidth_Rate &b); + friend bool operator>(const bandwidth_Rate &a, const bandwidth_Rate &b); + friend bool operator>=(const bandwidth_Rate &a, const bandwidth_Rate &b); + #if defined(__cpp_lib_three_way_comparison) + friend ::std::weak_ordering operator<=>(const bandwidth_Rate &a, const bandwidth_Rate &b); + #endif ::moq::buf debug() const; static bandwidth_Rate default_(); static ::moq::bandwidth_Rate ZERO(); @@ -6875,6 +6938,13 @@ namespace moq { ::std::uint64_t start; friend bool operator==(const group_Info &a, const group_Info &b); friend bool operator!=(const group_Info &a, const group_Info &b); + friend bool operator<(const group_Info &a, const group_Info &b); + friend bool operator<=(const group_Info &a, const group_Info &b); + friend bool operator>(const group_Info &a, const group_Info &b); + friend bool operator>=(const group_Info &a, const group_Info &b); + #if defined(__cpp_lib_three_way_comparison) + friend ::std::weak_ordering operator<=>(const group_Info &a, const group_Info &b); + #endif ::moq::buf debug() const; }; struct track_Delay { @@ -6890,6 +6960,13 @@ namespace moq { class track_Position { friend bool operator==(const track_Position &a, const track_Position &b); friend bool operator!=(const track_Position &a, const track_Position &b); + friend bool operator<(const track_Position &a, const track_Position &b); + friend bool operator<=(const track_Position &a, const track_Position &b); + friend bool operator>(const track_Position &a, const track_Position &b); + friend bool operator>=(const track_Position &a, const track_Position &b); + #if defined(__cpp_lib_three_way_comparison) + friend ::std::weak_ordering operator<=>(const track_Position &a, const track_Position &b); + #endif ::moq::buf debug() const; static track_Position default_(); ::std::uint64_t group_get() const; @@ -6912,6 +6989,13 @@ namespace moq { ::std::optional<::moq::track_Anchor> end; friend bool operator==(const track_Range &a, const track_Range &b); friend bool operator!=(const track_Range &a, const track_Range &b); + friend bool operator<(const track_Range &a, const track_Range &b); + friend bool operator<=(const track_Range &a, const track_Range &b); + friend bool operator>(const track_Range &a, const track_Range &b); + friend bool operator>=(const track_Range &a, const track_Range &b); + #if defined(__cpp_lib_three_way_comparison) + friend ::std::weak_ordering operator<=>(const track_Range &a, const track_Range &b); + #endif ::moq::buf debug() const; static ::moq::track_Range live(); static ::moq::track_Range oldest(); @@ -6919,6 +7003,13 @@ namespace moq { class origin_Cost { friend bool operator==(const origin_Cost &a, const origin_Cost &b); friend bool operator!=(const origin_Cost &a, const origin_Cost &b); + friend bool operator<(const origin_Cost &a, const origin_Cost &b); + friend bool operator<=(const origin_Cost &a, const origin_Cost &b); + friend bool operator>(const origin_Cost &a, const origin_Cost &b); + friend bool operator>=(const origin_Cost &a, const origin_Cost &b); + #if defined(__cpp_lib_three_way_comparison) + friend ::std::weak_ordering operator<=>(const origin_Cost &a, const origin_Cost &b); + #endif ::moq::buf debug() const; static origin_Cost default_(); static ::moq::origin_Cost new_(::std::uint64_t cost); @@ -6927,6 +7018,13 @@ namespace moq { class origin_Priority { friend bool operator==(const origin_Priority &a, const origin_Priority &b); friend bool operator!=(const origin_Priority &a, const origin_Priority &b); + friend bool operator<(const origin_Priority &a, const origin_Priority &b); + friend bool operator<=(const origin_Priority &a, const origin_Priority &b); + friend bool operator>(const origin_Priority &a, const origin_Priority &b); + friend bool operator>=(const origin_Priority &a, const origin_Priority &b); + #if defined(__cpp_lib_three_way_comparison) + friend ::std::weak_ordering operator<=>(const origin_Priority &a, const origin_Priority &b); + #endif ::moq::buf debug() const; static origin_Priority default_(); static ::moq::origin_Priority new_(::std::int8_t priority); @@ -7020,6 +7118,13 @@ namespace moq { }; inline bool operator==(const TimeOverflow &a, const TimeOverflow &b); inline bool operator==(const Timescale &a, const Timescale &b); + inline bool operator<(const Timescale &a, const Timescale &b); + inline bool operator<=(const Timescale &a, const Timescale &b); + inline bool operator>(const Timescale &a, const Timescale &b); + inline bool operator>=(const Timescale &a, const Timescale &b); + #if defined(__cpp_lib_three_way_comparison) + inline ::std::weak_ordering operator<=>(const Timescale &a, const Timescale &b); + #endif inline bool operator==(const setup_Token &a, const setup_Token &b); inline bool operator==(const session_Limits &a, const session_Limits &b); inline bool operator==(const stats_Content &a, const stats_Content &b); @@ -7034,16 +7139,65 @@ namespace moq { inline bool operator==(const stats_Routes &a, const stats_Routes &b); inline bool operator==(const stats_Withdrawals &a, const stats_Withdrawals &b); inline bool operator==(const bandwidth_Rate &a, const bandwidth_Rate &b); + inline bool operator<(const bandwidth_Rate &a, const bandwidth_Rate &b); + inline bool operator<=(const bandwidth_Rate &a, const bandwidth_Rate &b); + inline bool operator>(const bandwidth_Rate &a, const bandwidth_Rate &b); + inline bool operator>=(const bandwidth_Rate &a, const bandwidth_Rate &b); + #if defined(__cpp_lib_three_way_comparison) + inline ::std::weak_ordering operator<=>(const bandwidth_Rate &a, const bandwidth_Rate &b); + #endif inline bool operator==(const datagram_Datagram &a, const datagram_Datagram &b); inline bool operator==(const group_Info &a, const group_Info &b); + inline bool operator<(const group_Info &a, const group_Info &b); + inline bool operator<=(const group_Info &a, const group_Info &b); + inline bool operator>(const group_Info &a, const group_Info &b); + inline bool operator>=(const group_Info &a, const group_Info &b); + #if defined(__cpp_lib_three_way_comparison) + inline ::std::weak_ordering operator<=>(const group_Info &a, const group_Info &b); + #endif inline bool operator==(const track_Delay &a, const track_Delay &b); inline bool operator==(const track_Position &a, const track_Position &b); + inline bool operator<(const track_Position &a, const track_Position &b); + inline bool operator<=(const track_Position &a, const track_Position &b); + inline bool operator>(const track_Position &a, const track_Position &b); + inline bool operator>=(const track_Position &a, const track_Position &b); + #if defined(__cpp_lib_three_way_comparison) + inline ::std::weak_ordering operator<=>(const track_Position &a, const track_Position &b); + #endif inline bool operator==(const ::moq::track_Anchor &a, const ::moq::track_Anchor &b); inline bool operator!=(const ::moq::track_Anchor &a, const ::moq::track_Anchor &b); + inline bool operator<(const ::moq::track_Anchor &a, const ::moq::track_Anchor &b); + inline bool operator<=(const ::moq::track_Anchor &a, const ::moq::track_Anchor &b); + inline bool operator>(const ::moq::track_Anchor &a, const ::moq::track_Anchor &b); + inline bool operator>=(const ::moq::track_Anchor &a, const ::moq::track_Anchor &b); + #if defined(__cpp_lib_three_way_comparison) + inline ::std::weak_ordering operator<=>(const ::moq::track_Anchor &a, const ::moq::track_Anchor &b); + #endif inline ::moq::buf track_Anchor_debug(const ::moq::track_Anchor &self); inline bool operator==(const track_Range &a, const track_Range &b); + inline bool operator<(const track_Range &a, const track_Range &b); + inline bool operator<=(const track_Range &a, const track_Range &b); + inline bool operator>(const track_Range &a, const track_Range &b); + inline bool operator>=(const track_Range &a, const track_Range &b); + #if defined(__cpp_lib_three_way_comparison) + inline ::std::weak_ordering operator<=>(const track_Range &a, const track_Range &b); + #endif inline bool operator==(const origin_Cost &a, const origin_Cost &b); + inline bool operator<(const origin_Cost &a, const origin_Cost &b); + inline bool operator<=(const origin_Cost &a, const origin_Cost &b); + inline bool operator>(const origin_Cost &a, const origin_Cost &b); + inline bool operator>=(const origin_Cost &a, const origin_Cost &b); + #if defined(__cpp_lib_three_way_comparison) + inline ::std::weak_ordering operator<=>(const origin_Cost &a, const origin_Cost &b); + #endif inline bool operator==(const origin_Priority &a, const origin_Priority &b); + inline bool operator<(const origin_Priority &a, const origin_Priority &b); + inline bool operator<=(const origin_Priority &a, const origin_Priority &b); + inline bool operator>(const origin_Priority &a, const origin_Priority &b); + inline bool operator>=(const origin_Priority &a, const origin_Priority &b); + #if defined(__cpp_lib_three_way_comparison) + inline ::std::weak_ordering operator<=>(const origin_Priority &a, const origin_Priority &b); + #endif inline ::moq::buf EncodeError_to_string(::moq::EncodeError self); inline ::moq::buf EncodeError_debug(::moq::EncodeError self); inline bool operator==(const ::moq::SessionError &a, const ::moq::SessionError &b); @@ -7216,6 +7370,13 @@ namespace moq { Pattern &operator=(const Pattern &other) = default; friend bool operator==(const Pattern &a, const Pattern &b); friend bool operator!=(const Pattern &a, const Pattern &b); + friend bool operator<(const Pattern &a, const Pattern &b); + friend bool operator<=(const Pattern &a, const Pattern &b); + friend bool operator>(const Pattern &a, const Pattern &b); + friend bool operator>=(const Pattern &a, const Pattern &b); + #if defined(__cpp_lib_three_way_comparison) + friend ::std::weak_ordering operator<=>(const Pattern &a, const Pattern &b); + #endif RUST2_FFI_CALLABLE ::std::uint64_t hash() const; RUST2_FFI_CALLABLE ::moq::buf to_string() const; RUST2_FFI_CALLABLE ::moq::buf debug() const; @@ -7268,6 +7429,13 @@ namespace moq { Specificity &operator=(const Specificity &other) = default; friend bool operator==(const Specificity &a, const Specificity &b); friend bool operator!=(const Specificity &a, const Specificity &b); + friend bool operator<(const Specificity &a, const Specificity &b); + friend bool operator<=(const Specificity &a, const Specificity &b); + friend bool operator>(const Specificity &a, const Specificity &b); + friend bool operator>=(const Specificity &a, const Specificity &b); + #if defined(__cpp_lib_three_way_comparison) + friend ::std::weak_ordering operator<=>(const Specificity &a, const Specificity &b); + #endif RUST2_FFI_CALLABLE ::std::uint64_t hash() const; RUST2_FFI_CALLABLE ::moq::buf debug() const; }; @@ -7423,6 +7591,9 @@ namespace moq { #if defined(__cpp_impl_coroutine) && __cpp_impl_coroutine >= 201902L && __has_include() #include #endif +#if defined(__cpp_impl_three_way_comparison) && __cpp_impl_three_way_comparison >= 201907L && __has_include() +#include +#endif namespace moq { #if defined(__clang__) #define RUST2_FFI_LIFETIMEBOUND [[clang::lifetimebound]] @@ -8781,6 +8952,13 @@ namespace moq { Instant &operator=(const Instant &other) = default; friend bool operator==(const Instant &a, const Instant &b); friend bool operator!=(const Instant &a, const Instant &b); + friend bool operator<(const Instant &a, const Instant &b); + friend bool operator<=(const Instant &a, const Instant &b); + friend bool operator>(const Instant &a, const Instant &b); + friend bool operator>=(const Instant &a, const Instant &b); + #if defined(__cpp_lib_three_way_comparison) + friend ::std::weak_ordering operator<=>(const Instant &a, const Instant &b); + #endif RUST2_FFI_CALLABLE ::std::uint64_t hash() const; RUST2_FFI_CALLABLE ::moq::buf debug() const; }; @@ -8845,6 +9023,13 @@ namespace moq { tokio_Duration &operator=(const tokio_Duration &other) = default; friend bool operator==(const tokio_Duration &a, const tokio_Duration &b); friend bool operator!=(const tokio_Duration &a, const tokio_Duration &b); + friend bool operator<(const tokio_Duration &a, const tokio_Duration &b); + friend bool operator<=(const tokio_Duration &a, const tokio_Duration &b); + friend bool operator>(const tokio_Duration &a, const tokio_Duration &b); + friend bool operator>=(const tokio_Duration &a, const tokio_Duration &b); + #if defined(__cpp_lib_three_way_comparison) + friend ::std::weak_ordering operator<=>(const tokio_Duration &a, const tokio_Duration &b); + #endif RUST2_FFI_CALLABLE ::std::uint64_t hash() const; RUST2_FFI_CALLABLE ::moq::buf to_string() const; RUST2_FFI_CALLABLE ::moq::buf debug() const; @@ -9670,6 +9855,13 @@ namespace moq { }; inline bool operator==(::moq::Level a, ::moq::Level b); inline bool operator!=(::moq::Level a, ::moq::Level b); + inline bool operator<(::moq::Level a, ::moq::Level b); + inline bool operator<=(::moq::Level a, ::moq::Level b); + inline bool operator>(::moq::Level a, ::moq::Level b); + inline bool operator>=(::moq::Level a, ::moq::Level b); + #if defined(__cpp_lib_three_way_comparison) + inline ::std::weak_ordering operator<=>(::moq::Level a, ::moq::Level b); + #endif inline ::moq::buf Level_to_string(::moq::Level self); } #endif @@ -9686,6 +9878,13 @@ namespace moq { Url &operator=(const Url &other) = default; friend bool operator==(const Url &a, const Url &b); friend bool operator!=(const Url &a, const Url &b); + friend bool operator<(const Url &a, const Url &b); + friend bool operator<=(const Url &a, const Url &b); + friend bool operator>(const Url &a, const Url &b); + friend bool operator>=(const Url &a, const Url &b); + #if defined(__cpp_lib_three_way_comparison) + friend ::std::weak_ordering operator<=>(const Url &a, const Url &b); + #endif RUST2_FFI_CALLABLE ::std::uint64_t hash() const; RUST2_FFI_CALLABLE ::moq::buf to_string() const; RUST2_FFI_CALLABLE ::moq::buf debug() const; diff --git a/ffi/surface/moq/dart.dart b/ffi/surface/moq/dart.dart index 911580ecd..dc7c6bb9c 100644 --- a/ffi/surface/moq/dart.dart +++ b/ffi/surface/moq/dart.dart @@ -179,11 +179,17 @@ final class TimeOverflow implements Exception { @override bool operator ==(Object other); @override int get hashCode; } -final class Timescale { +final class Timescale implements Comparable { @override String toString(); String debug(); @override bool operator ==(Object other); @override int get hashCode; + int? partialCompareTo(Timescale other); + bool operator <(Timescale other); + bool operator <=(Timescale other); + bool operator >(Timescale other); + bool operator >=(Timescale other); + @override int compareTo(Timescale other); static Timescale get SECOND; static Timescale get MILLI; static Timescale get MICRO; @@ -191,10 +197,16 @@ final class Timescale { factory Timescale(U64 unitsPerSecond); U64 asU64(); } -final class ClockInstant { +final class ClockInstant implements Comparable { String debug(); @override bool operator ==(Object other); @override int get hashCode; + int? partialCompareTo(ClockInstant other); + bool operator <(ClockInstant other); + bool operator <=(ClockInstant other); + bool operator >(ClockInstant other); + bool operator >=(ClockInstant other); + @override int compareTo(ClockInstant other); static ClockInstant get ZERO; factory ClockInstant.now(); RustDuration elapsed(); @@ -214,10 +226,16 @@ final class ClockElapsed implements Exception { @override bool operator ==(Object other); @override int get hashCode; } -final class ClockWall { +final class ClockWall implements Comparable { String debug(); @override bool operator ==(Object other); @override int get hashCode; + int? partialCompareTo(ClockWall other); + bool operator <(ClockWall other); + bool operator <=(ClockWall other); + bool operator >(ClockWall other); + bool operator >=(ClockWall other); + @override int compareTo(ClockWall other); static ClockWall get UNIX_EPOCH; static ClockWall get MOQ_EPOCH; factory ClockWall.now(); @@ -463,10 +481,16 @@ final class StatsWithdrawals { StatsWithdrawals add(StatsWithdrawals other); bool regressed(StatsWithdrawals previous); } -final class BandwidthRate { +final class BandwidthRate implements Comparable { String debug(); @override bool operator ==(Object other); @override int get hashCode; + int? partialCompareTo(BandwidthRate other); + bool operator <(BandwidthRate other); + bool operator <=(BandwidthRate other); + bool operator >(BandwidthRate other); + bool operator >=(BandwidthRate other); + @override int compareTo(BandwidthRate other); factory BandwidthRate.default_(); static BandwidthRate get ZERO; factory BandwidthRate.fromBps(U64 bps); @@ -491,12 +515,18 @@ final class FrameInfo { const FrameInfo({required this.size, required this.timestamp}); String debug(); } -final class GroupInfo { +final class GroupInfo implements Comparable { final U64 start; const GroupInfo({required this.start}); String debug(); @override bool operator ==(Object other); @override int get hashCode; + int? partialCompareTo(GroupInfo other); + bool operator <(GroupInfo other); + bool operator <=(GroupInfo other); + bool operator >(GroupInfo other); + bool operator >=(GroupInfo other); + @override int compareTo(GroupInfo other); } final class TrackDelay { final RustDuration? min; @@ -509,10 +539,16 @@ final class TrackDelay { TrackDelay withMin(RustDuration? min); TrackDelay withMax(RustDuration? max); } -final class TrackPosition { +final class TrackPosition implements Comparable { String debug(); @override bool operator ==(Object other); @override int get hashCode; + int? partialCompareTo(TrackPosition other); + bool operator <(TrackPosition other); + bool operator <=(TrackPosition other); + bool operator >(TrackPosition other); + bool operator >=(TrackPosition other); + @override int compareTo(TrackPosition other); factory TrackPosition.default_(); U64 get groupGet; TrackPosition groupSet(U64 value); @@ -521,28 +557,46 @@ final class TrackPosition { factory TrackPosition(U64 group, U64 frame); factory TrackPosition.group(U64 group); } -final class TrackRange { +final class TrackRange implements Comparable { final TrackAnchor start; final TrackAnchor? end; const TrackRange({required this.start, required this.end}); String debug(); @override bool operator ==(Object other); @override int get hashCode; + int? partialCompareTo(TrackRange other); + bool operator <(TrackRange other); + bool operator <=(TrackRange other); + bool operator >(TrackRange other); + bool operator >=(TrackRange other); + @override int compareTo(TrackRange other); factory TrackRange.live(); factory TrackRange.oldest(); } -final class OriginCost { +final class OriginCost implements Comparable { String debug(); @override bool operator ==(Object other); @override int get hashCode; + int? partialCompareTo(OriginCost other); + bool operator <(OriginCost other); + bool operator <=(OriginCost other); + bool operator >(OriginCost other); + bool operator >=(OriginCost other); + @override int compareTo(OriginCost other); factory OriginCost.default_(); factory OriginCost(U64 cost); U64 value(); } -final class OriginPriority { +final class OriginPriority implements Comparable { String debug(); @override bool operator ==(Object other); @override int get hashCode; + int? partialCompareTo(OriginPriority other); + bool operator <(OriginPriority other); + bool operator <=(OriginPriority other); + bool operator >(OriginPriority other); + bool operator >=(OriginPriority other); + @override int compareTo(OriginPriority other); factory OriginPriority.default_(); factory OriginPriority(int priority); int value(); @@ -1178,11 +1232,17 @@ enum TrackCompression { String debug(); factory TrackCompression.default_(); } -sealed class TrackAnchor { +sealed class TrackAnchor implements Comparable { const TrackAnchor(); String debug(); @override bool operator ==(Object other); @override int get hashCode; + int? partialCompareTo(TrackAnchor other); + bool operator <(TrackAnchor other); + bool operator <=(TrackAnchor other); + bool operator >(TrackAnchor other); + bool operator >=(TrackAnchor other); + @override int compareTo(TrackAnchor other); } final class TrackAnchorRelative extends TrackAnchor { final U64 $0; @@ -1979,7 +2039,7 @@ enum MoqSockUdpEcnCodepoint { String debug(); static MoqSockUdpEcnCodepoint? fromBits(int x); } -enum Level { +enum Level implements Comparable { trace(0), debug(1), info(2), @@ -1987,6 +2047,12 @@ enum Level { error(4), const Level(this._c); @override String toString(); + int? partialCompareTo(Level other); + bool operator <(Level other); + bool operator <=(Level other); + bool operator >(Level other); + bool operator >=(Level other); + @override int compareTo(Level other); } final class Park extends _Object { String debug(); @@ -2023,22 +2089,34 @@ final class Driver extends _Object { String debug(); ClockInstant? poll(ClockInstant now, Waiter waiter); } -final class Instance extends _Object { +final class Instance extends _Object implements Comparable { @override String toString(); String debug(); Instance clone(); @override bool operator ==(Object other); @override int get hashCode; + int? partialCompareTo(Instance other); + bool operator <(Instance other); + bool operator <=(Instance other); + bool operator >(Instance other); + bool operator >=(Instance other); + @override int compareTo(Instance other); factory Instance.random(); String asStr(); bool isMinted(); } -final class Path extends _Object { +final class Path extends _Object implements Comparable { @override String toString(); String debug(); Path clone(); @override bool operator ==(Object other); @override int get hashCode; + int? partialCompareTo(Path other); + bool operator <(Path other); + bool operator <=(Path other); + bool operator >(Path other); + bool operator >=(Path other); + @override int compareTo(Path other); factory Path.default_(); factory Path(String s); factory Path.fromStatic(String s); @@ -2054,12 +2132,18 @@ final class Path extends _Object { Path? tryResolve(PathRelative rel); PathRelative? relative(Path base); } -final class Pattern extends _Object { +final class Pattern extends _Object implements Comparable { @override String toString(); String debug(); Pattern clone(); @override bool operator ==(Object other); @override int get hashCode; + int? partialCompareTo(Pattern other); + bool operator <(Pattern other); + bool operator <=(Pattern other); + bool operator >(Pattern other); + bool operator >=(Pattern other); + @override int compareTo(Pattern other); factory Pattern.default_(); factory Pattern(List segments); factory Pattern.all(); @@ -2175,6 +2259,11 @@ final class Timestamp extends _Object { Timestamp clone(); @override bool operator ==(Object other); @override int get hashCode; + int? partialCompareTo(Timestamp other); + bool operator <(Timestamp other); + bool operator <=(Timestamp other); + bool operator >(Timestamp other); + bool operator >=(Timestamp other); static Timestamp get ZERO; factory Timestamp(U64 value, Timescale scale); factory Timestamp.unscaled(U64 key); @@ -2218,11 +2307,17 @@ final class Versions extends _Object { bool contains(Version version); List iter(); } -final class Specificity extends _Object { +final class Specificity extends _Object implements Comparable { String debug(); Specificity clone(); @override bool operator ==(Object other); @override int get hashCode; + int? partialCompareTo(Specificity other); + bool operator <(Specificity other); + bool operator <=(Specificity other); + bool operator >(Specificity other); + bool operator >=(Specificity other); + @override int compareTo(Specificity other); } final class ClockClock extends _Object { String debug(); @@ -2465,12 +2560,18 @@ final class MuxError extends _Object implements Exception { String debug(); MuxError clone(); } -final class TokioDuration extends _Object { +final class TokioDuration extends _Object implements Comparable { @override String toString(); String debug(); TokioDuration clone(); @override bool operator ==(Object other); @override int get hashCode; + int? partialCompareTo(TokioDuration other); + bool operator <(TokioDuration other); + bool operator <=(TokioDuration other); + bool operator >(TokioDuration other); + bool operator >=(TokioDuration other); + @override int compareTo(TokioDuration other); factory TokioDuration.default_(); } final class TokioBackoff extends _Object { @@ -7651,23 +7752,35 @@ final class MoqTokioQuicDemuxDatagram extends _Object { final class MoqSockDemuxPin extends _Object { String debug(); } -final class Url extends _Object { +final class Url extends _Object implements Comparable { @override String toString(); String debug(); Url clone(); @override bool operator ==(Object other); @override int get hashCode; + int? partialCompareTo(Url other); + bool operator <(Url other); + bool operator <=(Url other); + bool operator >(Url other); + bool operator >=(Url other); + @override int compareTo(Url other); factory Url.parse(String input); } final class Json extends _Object { factory Json.parse(String input); String toText(); } -final class Instant extends _Object { +final class Instant extends _Object implements Comparable { String debug(); Instant clone(); @override bool operator ==(Object other); @override int get hashCode; + int? partialCompareTo(Instant other); + bool operator <(Instant other); + bool operator <=(Instant other); + bool operator >(Instant other); + bool operator >=(Instant other); + @override int compareTo(Instant other); } final class RustlsServerConfig extends _Object { RustlsServerConfig clone(); diff --git a/ffi/surface/moq/go.txt b/ffi/surface/moq/go.txt index 24b635f79..4f8a601a4 100644 --- a/ffi/surface/moq/go.txt +++ b/ffi/surface/moq/go.txt @@ -1002,11 +1002,13 @@ func ClockNow() ClockInstant func (self ClockInstant) CheckedAdd(duration p_rt.Duration) *ClockInstant func (self ClockInstant) CheckedDurationSince(earlier ClockInstant) *p_rt.Duration func (self ClockInstant) CheckedSub(duration p_rt.Duration) *ClockInstant +func (self ClockInstant) Compare(other ClockInstant) int func (self ClockInstant) DurationSince(earlier ClockInstant) p_rt.Duration func (self ClockInstant) Elapsed() p_rt.Duration func (self ClockInstant) Equal(other ClockInstant) bool func (self ClockInstant) GoString() string func (self ClockInstant) IntoStd() *p_std.Instant +func (self ClockInstant) PartialCompare(other ClockInstant) (int, bool) func (self ClockInstant) SaturatingAdd(duration p_rt.Duration) ClockInstant func (self ClockInstant) SaturatingDurationSince(earlier ClockInstant) p_rt.Duration func (self ClockInstant) SaturatingSub(duration p_rt.Duration) ClockInstant @@ -1057,8 +1059,10 @@ func NewClockWall() ClockWall func (self ClockWall) CheckedAdd(duration p_rt.Duration) *ClockWall func (self ClockWall) CheckedDurationSince(earlier ClockWall) *p_rt.Duration func (self ClockWall) CheckedSub(duration p_rt.Duration) *ClockWall +func (self ClockWall) Compare(other ClockWall) int func (self ClockWall) Equal(other ClockWall) bool func (self ClockWall) GoString() string +func (self ClockWall) PartialCompare(other ClockWall) (int, bool) func (self ClockWall) SaturatingAdd(duration p_rt.Duration) ClockWall func (self ClockWall) SaturatingDurationSince(earlier ClockWall) p_rt.Duration type ClockWallMap struct { @@ -5452,8 +5456,10 @@ func BandwidthRateZERO() BandwidthRate func BandwidthViewersMAX_TARGET() BandwidthRate func (self BandwidthRate) AbsDiff(other_ BandwidthRate) BandwidthRate func (self BandwidthRate) AsBps() uint64 +func (self BandwidthRate) Compare(other BandwidthRate) int func (self BandwidthRate) Equal(other BandwidthRate) bool func (self BandwidthRate) GoString() string +func (self BandwidthRate) PartialCompare(other BandwidthRate) (int, bool) func (self BandwidthRate) Scaled(factor float64) BandwidthRate type BandwidthReservation struct { Handle_ *p_rt.Handle_ @@ -5844,8 +5850,10 @@ func (self *GroupFinished) StartGet() (uint64, error) type GroupInfo struct { Start uint64 } +func (self GroupInfo) Compare(other GroupInfo) int func (self GroupInfo) Equal(other GroupInfo) bool func (self GroupInfo) GoString() string +func (self GroupInfo) PartialCompare(other GroupInfo) (int, bool) type GroupProducer struct { Handle_ *p_rt.Handle_ } @@ -5870,9 +5878,11 @@ func InstanceRandom() *Instance func (self *Instance) AsStr() (string, error) func (self *Instance) Clone() (*Instance, error) func (self *Instance) Close() error +func (self *Instance) Compare(other *Instance) (int, error) func (self *Instance) Equal(other *Instance) (bool, error) func (self *Instance) GoString() string func (self *Instance) IsMinted() (bool, error) +func (self *Instance) PartialCompare(other *Instance) (int, bool, error) func (self *Instance) String() string type OriginClaim struct { Handle_ *p_rt.Handle_ @@ -5927,8 +5937,10 @@ type OriginCost struct { } func NewOriginCost(cost uint64) OriginCost func OriginCostDefault() OriginCost +func (self OriginCost) Compare(other OriginCost) int func (self OriginCost) Equal(other OriginCost) bool func (self OriginCost) GoString() string +func (self OriginCost) PartialCompare(other OriginCost) (int, bool) func (self OriginCost) Value() uint64 type OriginDriver struct { Handle_ *p_rt.Handle_ @@ -5955,8 +5967,10 @@ type OriginPriority struct { } func NewOriginPriority(priority int8) OriginPriority func OriginPriorityDefault() OriginPriority +func (self OriginPriority) Compare(other OriginPriority) int func (self OriginPriority) Equal(other OriginPriority) bool func (self OriginPriority) GoString() string +func (self OriginPriority) PartialCompare(other OriginPriority) (int, bool) func (self OriginPriority) Value() int8 type OriginProducer struct { Handle_ *p_rt.Handle_ @@ -6061,6 +6075,7 @@ func PathFromStatic(s string) (*Path, error) func (self *Path) AsStr() (string, error) func (self *Path) Clone() (*Path, error) func (self *Path) Close() error +func (self *Path) Compare(other *Path) (int, error) func (self *Path) Equal(other *Path) (bool, error) func (self *Path) GoString() string func (self *Path) HasPrefix(prefix *Path) (bool, error) @@ -6068,6 +6083,7 @@ func (self *Path) Head(n uint) (*Path, error) func (self *Path) IsEmpty() (bool, error) func (self *Path) Join(other_ *Path) (*Path, error) func (self *Path) Len() (uint, error) +func (self *Path) PartialCompare(other *Path) (int, bool, error) func (self *Path) Relative(base *Path) (*PathRelative, error) func (self *Path) Resolve(rel *PathRelative) (*Path, error) func (self *Path) String() string @@ -6994,8 +7010,10 @@ func TimescaleMILLI() Timescale func TimescaleNANO() Timescale func TimescaleSECOND() Timescale func (self Timescale) AsU64() uint64 +func (self Timescale) Compare(other Timescale) int func (self Timescale) Equal(other Timescale) bool func (self Timescale) GoString() string +func (self Timescale) PartialCompare(other Timescale) (int, bool) func (self Timescale) String() string type Timestamp struct { Handle_ *p_rt.Handle_ @@ -7021,6 +7039,7 @@ func (self *Timestamp) Convert(newScale Timescale) (*Timestamp, error) func (self *Timestamp) Equal(other *Timestamp) (bool, error) func (self *Timestamp) GoString() string func (self *Timestamp) IsZero() (bool, error) +func (self *Timestamp) PartialCompare(other *Timestamp) (int, bool, error) func (self *Timestamp) Scale() (*Timescale, error) func (self *Timestamp) Value() (uint64, error) type TrackAbortHandle struct { @@ -7033,21 +7052,29 @@ func (self *TrackAbortHandle) IsClosed() (bool, error) type TrackAnchor interface { GoString() string Equal(other TrackAnchor) bool + PartialCompare(other TrackAnchor) (int, bool) + Compare(other TrackAnchor) int } type TrackAnchorOldest struct { } +func (self TrackAnchorOldest) Compare(other TrackAnchor) int func (self TrackAnchorOldest) Equal(other TrackAnchor) bool func (self TrackAnchorOldest) GoString() string +func (self TrackAnchorOldest) PartialCompare(other TrackAnchor) (int, bool) type TrackAnchorRelative struct { V0 uint64 } +func (self TrackAnchorRelative) Compare(other TrackAnchor) int func (self TrackAnchorRelative) Equal(other TrackAnchor) bool func (self TrackAnchorRelative) GoString() string +func (self TrackAnchorRelative) PartialCompare(other TrackAnchor) (int, bool) type TrackAnchorTime struct { V0 uint64 } +func (self TrackAnchorTime) Compare(other TrackAnchor) int func (self TrackAnchorTime) Equal(other TrackAnchor) bool func (self TrackAnchorTime) GoString() string +func (self TrackAnchorTime) PartialCompare(other TrackAnchor) (int, bool) type TrackCompression int32 const ( TrackCompressionNone TrackCompression = 0 @@ -7173,12 +7200,14 @@ type TrackPosition struct { func NewTrackPosition(group uint64, frame uint64) TrackPosition func TrackPositionDefault() TrackPosition func TrackPositionGroup(group uint64) TrackPosition +func (self TrackPosition) Compare(other TrackPosition) int func (self TrackPosition) Equal(other TrackPosition) bool func (self TrackPosition) FrameGet() uint64 func (self *TrackPosition) FrameSet(value uint64) func (self TrackPosition) GoString() string func (self TrackPosition) GroupGet() uint64 func (self *TrackPosition) GroupSet(value uint64) +func (self TrackPosition) PartialCompare(other TrackPosition) (int, bool) type TrackProducer struct { Handle_ *p_rt.Handle_ } @@ -7216,8 +7245,10 @@ type TrackRange struct { } func TrackRangeLive() TrackRange func TrackRangeOldest() TrackRange +func (self TrackRange) Compare(other TrackRange) int func (self TrackRange) Equal(other TrackRange) bool func (self TrackRange) GoString() string +func (self TrackRange) PartialCompare(other TrackRange) (int, bool) type TrackRefresh struct { Handle_ *p_rt.Handle_ } @@ -7521,6 +7552,7 @@ func (self *Pattern) AsStr() (string, error) func (self *Pattern) Captures(matched *Pattern) (*[]*Pattern, error) func (self *Pattern) Clone() (*Pattern, error) func (self *Pattern) Close() error +func (self *Pattern) Compare(other *Pattern) (int, error) func (self *Pattern) Contains(other_ *Pattern) (bool, error) func (self *Pattern) Equal(other *Pattern) (bool, error) func (self *Pattern) GoString() string @@ -7530,6 +7562,7 @@ func (self *Pattern) Intersect(other_ *Pattern) (*Patterns, error) func (self *Pattern) IsLiteral() (bool, error) func (self *Pattern) Matches(path string) (bool, error) func (self *Pattern) Overlaps(other_ *Pattern) (bool, error) +func (self *Pattern) PartialCompare(other *Pattern) (int, bool, error) func (self *Pattern) Rebase(root string) (*Patterns, error) func (self *Pattern) Rooted(root string) (*Pattern, error) func (self *Pattern) Segments() ([]Segment, error) @@ -7588,8 +7621,10 @@ type Specificity struct { } func (self *Specificity) Clone() (*Specificity, error) func (self *Specificity) Close() error +func (self *Specificity) Compare(other *Specificity) (int, error) func (self *Specificity) Equal(other *Specificity) (bool, error) func (self *Specificity) GoString() string +func (self *Specificity) PartialCompare(other *Specificity) (int, bool, error) package qmux // import "moq/qmux" @@ -8090,8 +8125,10 @@ type Instant struct { } func (self *Instant) Clone() (*Instant, error) func (self *Instant) Close() error +func (self *Instant) Compare(other *Instant) (int, error) func (self *Instant) Equal(other *Instant) (bool, error) func (self *Instant) GoString() string +func (self *Instant) PartialCompare(other *Instant) (int, bool, error) package tokio // import "moq/tokio" @@ -8390,8 +8427,10 @@ type Duration struct { func DurationDefault() *Duration func (self *Duration) Clone() (*Duration, error) func (self *Duration) Close() error +func (self *Duration) Compare(other *Duration) (int, error) func (self *Duration) Equal(other *Duration) (bool, error) func (self *Duration) GoString() string +func (self *Duration) PartialCompare(other *Duration) (int, bool, error) func (self *Duration) String() string type Error struct { Handle_ *p_rt.Handle_ @@ -8948,7 +8987,9 @@ const ( LevelWarn Level = 3 LevelError Level = 4 ) +func (self Level) Compare(other Level) int func (self Level) Equal(other Level) bool +func (self Level) PartialCompare(other Level) (int, bool) func (self Level) String() string package url // import "moq/url" @@ -8960,7 +9001,9 @@ type Url struct { func UrlParse(input string) (*Url, error) func (self *Url) Clone() (*Url, error) func (self *Url) Close() error +func (self *Url) Compare(other *Url) (int, error) func (self *Url) Equal(other *Url) (bool, error) func (self *Url) GoString() string +func (self *Url) PartialCompare(other *Url) (int, bool, error) func (self *Url) String() string diff --git a/ffi/surface/moq/kotlin.kt b/ffi/surface/moq/kotlin.kt index 9267adda9..298a3f726 100644 --- a/ffi/surface/moq/kotlin.kt +++ b/ffi/surface/moq/kotlin.kt @@ -127,9 +127,11 @@ class ArrayU8x6(bytes: ByteArray) { final override fun toString(): kotlin.String fun debug(): kotlin.String } -@kotlin.jvm.JvmInline value class Timescale internal constructor(internal val bits: Long) { +@kotlin.jvm.JvmInline value class Timescale internal constructor(internal val bits: Long) : kotlin.Comparable { final override fun toString(): kotlin.String fun debug(): kotlin.String + fun partialCompareTo(other: moq.Timescale): kotlin.Int? + override fun compareTo(other: moq.Timescale): kotlin.Int fun asU64(): kotlin.ULong companion object { @kotlin.jvm.JvmStatic val SECOND: moq.Timescale @@ -139,8 +141,10 @@ class ArrayU8x6(bytes: ByteArray) { @kotlin.jvm.JvmStatic @kotlin.jvm.Throws(TimeOverflowException::class) fun new(unitsPerSecond: kotlin.ULong): moq.Timescale } } -@kotlin.jvm.JvmInline value class ClockInstant internal constructor(internal val bits: Long) { +@kotlin.jvm.JvmInline value class ClockInstant internal constructor(internal val bits: Long) : kotlin.Comparable { fun debug(): kotlin.String + fun partialCompareTo(other: moq.ClockInstant): kotlin.Int? + override fun compareTo(other: moq.ClockInstant): kotlin.Int fun elapsed(): moq.Duration fun durationSince(earlier: moq.ClockInstant): moq.Duration fun checkedDurationSince(earlier: moq.ClockInstant): moq.Duration? @@ -160,8 +164,10 @@ class ArrayU8x6(bytes: ByteArray) { final override fun toString(): kotlin.String fun debug(): kotlin.String } -@kotlin.jvm.JvmInline value class ClockWall internal constructor(internal val bits: Long) { +@kotlin.jvm.JvmInline value class ClockWall internal constructor(internal val bits: Long) : kotlin.Comparable { fun debug(): kotlin.String + fun partialCompareTo(other: moq.ClockWall): kotlin.Int? + override fun compareTo(other: moq.ClockWall): kotlin.Int fun checkedDurationSince(earlier: moq.ClockWall): moq.Duration? fun saturatingDurationSince(earlier: moq.ClockWall): moq.Duration fun checkedAdd(duration: moq.Duration): moq.ClockWall? @@ -426,8 +432,10 @@ class StatsWithdrawals internal constructor() { @kotlin.jvm.JvmStatic fun default(): moq.StatsWithdrawals } } -@kotlin.jvm.JvmInline value class BandwidthRate internal constructor(internal val bits: Long) { +@kotlin.jvm.JvmInline value class BandwidthRate internal constructor(internal val bits: Long) : kotlin.Comparable { fun debug(): kotlin.String + fun partialCompareTo(other: moq.BandwidthRate): kotlin.Int? + override fun compareTo(other: moq.BandwidthRate): kotlin.Int fun asBps(): kotlin.ULong fun scaled(factor: kotlin.Double): moq.BandwidthRate fun absDiff(other: moq.BandwidthRate): moq.BandwidthRate @@ -445,8 +453,10 @@ data class DatagramDatagram(val sequence: kotlin.ULong, val timestamp: moq.Times data class FrameInfo(val size: kotlin.ULong, val timestamp: moq.Timestamp) { fun debug(): kotlin.String } -data class GroupInfo(val start: kotlin.ULong) { +data class GroupInfo(val start: kotlin.ULong) : kotlin.Comparable { fun debug(): kotlin.String + fun partialCompareTo(other: moq.GroupInfo): kotlin.Int? + override fun compareTo(other: moq.GroupInfo): kotlin.Int } data class TrackDelay(val min: moq.Duration?, val max: moq.Duration?) { fun debug(): kotlin.String @@ -456,10 +466,12 @@ data class TrackDelay(val min: moq.Duration?, val max: moq.Duration?) { @kotlin.jvm.JvmStatic fun default(): moq.TrackDelay } } -class TrackPosition internal constructor() { +class TrackPosition internal constructor() : kotlin.Comparable { fun debug(): kotlin.String override fun equals(other: kotlin.Any?): kotlin.Boolean override fun hashCode(): kotlin.Int + fun partialCompareTo(other: moq.TrackPosition): kotlin.Int? + override fun compareTo(other: moq.TrackPosition): kotlin.Int val groupGet: kotlin.ULong fun groupSet(value: kotlin.ULong): moq.TrackPosition val frameGet: kotlin.ULong @@ -470,23 +482,29 @@ class TrackPosition internal constructor() { @kotlin.jvm.JvmStatic fun group(group: kotlin.ULong): moq.TrackPosition } } -data class TrackRange(val start: moq.TrackAnchor, val end: moq.TrackAnchor?) { +data class TrackRange(val start: moq.TrackAnchor, val end: moq.TrackAnchor?) : kotlin.Comparable { fun debug(): kotlin.String + fun partialCompareTo(other: moq.TrackRange): kotlin.Int? + override fun compareTo(other: moq.TrackRange): kotlin.Int companion object { @kotlin.jvm.JvmStatic fun live(): moq.TrackRange @kotlin.jvm.JvmStatic fun oldest(): moq.TrackRange } } -@kotlin.jvm.JvmInline value class OriginCost internal constructor(internal val bits: Long) { +@kotlin.jvm.JvmInline value class OriginCost internal constructor(internal val bits: Long) : kotlin.Comparable { fun debug(): kotlin.String + fun partialCompareTo(other: moq.OriginCost): kotlin.Int? + override fun compareTo(other: moq.OriginCost): kotlin.Int fun value(): kotlin.ULong companion object { @kotlin.jvm.JvmStatic fun default(): moq.OriginCost @kotlin.jvm.JvmStatic fun new(cost: kotlin.ULong): moq.OriginCost } } -@kotlin.jvm.JvmInline value class OriginPriority internal constructor(internal val bits: Long) { +@kotlin.jvm.JvmInline value class OriginPriority internal constructor(internal val bits: Long) : kotlin.Comparable { fun debug(): kotlin.String + fun partialCompareTo(other: moq.OriginPriority): kotlin.Int? + override fun compareTo(other: moq.OriginPriority): kotlin.Int fun value(): kotlin.Byte companion object { @kotlin.jvm.JvmStatic fun default(): moq.OriginPriority @@ -906,11 +924,13 @@ enum class TrackCompression(internal val value: Int) { @kotlin.jvm.JvmStatic fun default(): moq.TrackCompression } } -sealed class TrackAnchor { +sealed class TrackAnchor : kotlin.Comparable { data class Relative(val _0: kotlin.ULong) : TrackAnchor() data object Oldest : TrackAnchor() data class Time(val _0: kotlin.ULong) : TrackAnchor() fun debug(): kotlin.String + fun partialCompareTo(other: moq.TrackAnchor): kotlin.Int? + override fun compareTo(other: moq.TrackAnchor): kotlin.Int } enum class TrackOrder(internal val value: Int) { ASCENDING(0), @@ -1359,6 +1379,7 @@ enum class Level(internal val value: Int) { WARN(3), ERROR(4); final override fun toString(): kotlin.String + fun partialCompareTo(other: moq.Level): kotlin.Int? companion object {} } class Park internal constructor(raw: Long, lent: Boolean = false) : AutoCloseable { @@ -1407,26 +1428,30 @@ class Driver internal constructor(raw: Long, lent: Boolean = false) : AutoClosea fun debug(): kotlin.String @kotlin.jvm.Throws(ErrorException::class) fun poll(now: moq.ClockInstant, waiter: moq.Waiter): moq.ClockInstant? } -class Instance internal constructor(raw: Long, lent: Boolean = false) : AutoCloseable { +class Instance internal constructor(raw: Long, lent: Boolean = false) : AutoCloseable, kotlin.Comparable { override fun close() final override fun toString(): kotlin.String fun debug(): kotlin.String fun clone(): moq.Instance override fun equals(other: kotlin.Any?): kotlin.Boolean override fun hashCode(): kotlin.Int + fun partialCompareTo(other: moq.Instance): kotlin.Int? + override fun compareTo(other: moq.Instance): kotlin.Int fun asStr(): kotlin.String fun isMinted(): kotlin.Boolean companion object { @kotlin.jvm.JvmStatic fun random(): moq.Instance } } -class Path internal constructor(raw: Long, lent: Boolean = false) : AutoCloseable { +class Path internal constructor(raw: Long, lent: Boolean = false) : AutoCloseable, kotlin.Comparable { override fun close() final override fun toString(): kotlin.String fun debug(): kotlin.String fun clone(): moq.Path override fun equals(other: kotlin.Any?): kotlin.Boolean override fun hashCode(): kotlin.Int + fun partialCompareTo(other: moq.Path): kotlin.Int? + override fun compareTo(other: moq.Path): kotlin.Int fun hasPrefix(prefix: moq.Path): kotlin.Boolean fun stripPrefix(prefix: moq.Path): moq.Path? fun head(n: kotlin.ULong): moq.Path? @@ -1444,13 +1469,15 @@ class Path internal constructor(raw: Long, lent: Boolean = false) : AutoCloseabl @kotlin.jvm.JvmStatic fun empty(): moq.Path } } -class Pattern internal constructor(raw: Long, lent: Boolean = false) : AutoCloseable { +class Pattern internal constructor(raw: Long, lent: Boolean = false) : AutoCloseable, kotlin.Comparable { override fun close() final override fun toString(): kotlin.String fun debug(): kotlin.String fun clone(): moq.Pattern override fun equals(other: kotlin.Any?): kotlin.Boolean override fun hashCode(): kotlin.Int + fun partialCompareTo(other: moq.Pattern): kotlin.Int? + override fun compareTo(other: moq.Pattern): kotlin.Int fun asStr(): kotlin.String fun segments(): kotlin.collections.List fun head(): kotlin.String @@ -1582,6 +1609,7 @@ class Timestamp internal constructor(raw: Long, lent: Boolean = false) : AutoClo fun clone(): moq.Timestamp override fun equals(other: kotlin.Any?): kotlin.Boolean override fun hashCode(): kotlin.Int + fun partialCompareTo(other: moq.Timestamp): kotlin.Int? fun value(): kotlin.ULong fun scale(): moq.Timescale? fun isZero(): kotlin.Boolean @@ -1633,12 +1661,14 @@ class Versions internal constructor(raw: Long, lent: Boolean = false) : AutoClos @kotlin.jvm.JvmStatic fun all(): moq.Versions } } -class Specificity internal constructor(raw: Long, lent: Boolean = false) : AutoCloseable { +class Specificity internal constructor(raw: Long, lent: Boolean = false) : AutoCloseable, kotlin.Comparable { override fun close() fun debug(): kotlin.String fun clone(): moq.Specificity override fun equals(other: kotlin.Any?): kotlin.Boolean override fun hashCode(): kotlin.Int + fun partialCompareTo(other: moq.Specificity): kotlin.Int? + override fun compareTo(other: moq.Specificity): kotlin.Int } class ClockClock internal constructor(raw: Long, lent: Boolean = false) : AutoCloseable { override fun close() @@ -1931,13 +1961,15 @@ class MuxError internal constructor(raw: Long, lent: Boolean = false) : AutoClos fun debug(): kotlin.String fun clone(): moq.MuxError } -class TokioDuration internal constructor(raw: Long, lent: Boolean = false) : AutoCloseable { +class TokioDuration internal constructor(raw: Long, lent: Boolean = false) : AutoCloseable, kotlin.Comparable { override fun close() final override fun toString(): kotlin.String fun debug(): kotlin.String fun clone(): moq.TokioDuration override fun equals(other: kotlin.Any?): kotlin.Boolean override fun hashCode(): kotlin.Int + fun partialCompareTo(other: moq.TokioDuration): kotlin.Int? + override fun compareTo(other: moq.TokioDuration): kotlin.Int companion object { @kotlin.jvm.JvmStatic fun default(): moq.TokioDuration } @@ -7957,13 +7989,15 @@ class MoqSockDemuxPin internal constructor(raw: Long, lent: Boolean = false) : A override fun close() fun debug(): kotlin.String } -class Url internal constructor(raw: Long, lent: Boolean = false) : AutoCloseable { +class Url internal constructor(raw: Long, lent: Boolean = false) : AutoCloseable, kotlin.Comparable { override fun close() final override fun toString(): kotlin.String fun debug(): kotlin.String fun clone(): moq.Url override fun equals(other: kotlin.Any?): kotlin.Boolean override fun hashCode(): kotlin.Int + fun partialCompareTo(other: moq.Url): kotlin.Int? + override fun compareTo(other: moq.Url): kotlin.Int companion object { @kotlin.jvm.JvmStatic @kotlin.jvm.Throws(StringException::class) fun parse(input: kotlin.String): moq.Url } @@ -7975,12 +8009,14 @@ class Json internal constructor(raw: Long, lent: Boolean = false) : AutoCloseabl @kotlin.jvm.JvmStatic @kotlin.jvm.Throws(StringException::class) fun parse(input: kotlin.String): moq.Json } } -class Instant internal constructor(raw: Long, lent: Boolean = false) : AutoCloseable { +class Instant internal constructor(raw: Long, lent: Boolean = false) : AutoCloseable, kotlin.Comparable { override fun close() fun debug(): kotlin.String fun clone(): moq.Instant override fun equals(other: kotlin.Any?): kotlin.Boolean override fun hashCode(): kotlin.Int + fun partialCompareTo(other: moq.Instant): kotlin.Int? + override fun compareTo(other: moq.Instant): kotlin.Int } class RustlsServerConfig internal constructor(raw: Long, lent: Boolean = false) : AutoCloseable { override fun close() diff --git a/ffi/surface/moq/python.pyi b/ffi/surface/moq/python.pyi index 4bd865dd7..c45660cfa 100644 --- a/ffi/surface/moq/python.pyi +++ b/ffi/surface/moq/python.pyi @@ -43,6 +43,10 @@ class TimeOverflow(_n.Value): def __repr__(self) -> _str: ... class Timescale(_n.Value): def __eq__(self, other: _object) -> _bool: ... + def __lt__(self, other: _object) -> _bool: ... + def __le__(self, other: _object) -> _bool: ... + def __gt__(self, other: _object) -> _bool: ... + def __ge__(self, other: _object) -> _bool: ... def __str__(self) -> _str: ... def __repr__(self) -> _str: ... def __hash__(self) -> _int: ... @@ -59,6 +63,10 @@ class Timescale(_n.Value): NANO = _Const(_n.Timescale_NANO) class ClockInstant(_n.Value): def __eq__(self, other: _object) -> _bool: ... + def __lt__(self, other: _object) -> _bool: ... + def __le__(self, other: _object) -> _bool: ... + def __gt__(self, other: _object) -> _bool: ... + def __ge__(self, other: _object) -> _bool: ... def __repr__(self) -> _str: ... def __hash__(self) -> _int: ... ZERO = _n.clock_Instant_ZERO() @@ -82,6 +90,10 @@ class ClockElapsed(_n.Value): def __repr__(self) -> _str: ... class ClockWall(_n.Value): def __eq__(self, other: _object) -> _bool: ... + def __lt__(self, other: _object) -> _bool: ... + def __le__(self, other: _object) -> _bool: ... + def __gt__(self, other: _object) -> _bool: ... + def __ge__(self, other: _object) -> _bool: ... def __repr__(self) -> _str: ... def __hash__(self) -> _int: ... UNIX_EPOCH = _n.clock_Wall_UNIX_EPOCH() @@ -384,6 +396,10 @@ class StatsWithdrawals(_n.Value): def regressed(self, previous: StatsWithdrawals) -> _bool: ... class BandwidthRate(_n.Value): def __eq__(self, other: _object) -> _bool: ... + def __lt__(self, other: _object) -> _bool: ... + def __le__(self, other: _object) -> _bool: ... + def __gt__(self, other: _object) -> _bool: ... + def __ge__(self, other: _object) -> _bool: ... def __repr__(self) -> _str: ... def __hash__(self) -> _int: ... @_staticmethod @@ -416,6 +432,10 @@ class GroupInfo(_Record): start: _int def __init__(self, start: _int) -> None: ... def __eq__(self, other: _object) -> _bool: ... + def __lt__(self, other: _object) -> _bool: ... + def __le__(self, other: _object) -> _bool: ... + def __gt__(self, other: _object) -> _bool: ... + def __ge__(self, other: _object) -> _bool: ... def __repr__(self) -> _str: ... class TrackDelay(_Record): min: Duration | None @@ -429,6 +449,10 @@ class TrackDelay(_Record): def with_max(self, max: Duration | None) -> TrackDelay: ... class TrackPosition(_n.Value): def __eq__(self, other: _object) -> _bool: ... + def __lt__(self, other: _object) -> _bool: ... + def __le__(self, other: _object) -> _bool: ... + def __gt__(self, other: _object) -> _bool: ... + def __ge__(self, other: _object) -> _bool: ... def __repr__(self) -> _str: ... def __hash__(self) -> _int: ... @_staticmethod @@ -448,6 +472,10 @@ class TrackRange(_Record): end: TrackAnchor | None def __init__(self, start: TrackAnchor, end: TrackAnchor | None) -> None: ... def __eq__(self, other: _object) -> _bool: ... + def __lt__(self, other: _object) -> _bool: ... + def __le__(self, other: _object) -> _bool: ... + def __gt__(self, other: _object) -> _bool: ... + def __ge__(self, other: _object) -> _bool: ... def __repr__(self) -> _str: ... @_staticmethod def live() -> TrackRange: ... @@ -455,6 +483,10 @@ class TrackRange(_Record): def oldest() -> TrackRange: ... class OriginCost(_n.Value): def __eq__(self, other: _object) -> _bool: ... + def __lt__(self, other: _object) -> _bool: ... + def __le__(self, other: _object) -> _bool: ... + def __gt__(self, other: _object) -> _bool: ... + def __ge__(self, other: _object) -> _bool: ... def __repr__(self) -> _str: ... @_staticmethod def default() -> OriginCost: ... @@ -463,6 +495,10 @@ class OriginCost(_n.Value): def value(self) -> _int: ... class OriginPriority(_n.Value): def __eq__(self, other: _object) -> _bool: ... + def __lt__(self, other: _object) -> _bool: ... + def __le__(self, other: _object) -> _bool: ... + def __gt__(self, other: _object) -> _bool: ... + def __ge__(self, other: _object) -> _bool: ... def __repr__(self) -> _str: ... def __hash__(self) -> _int: ... @_staticmethod @@ -1035,6 +1071,10 @@ class TrackCompression(_enum.Enum): @_staticmethod def default() -> TrackCompression: ... class TrackAnchor: + def __lt__(self, other: _object) -> _bool: ... + def __le__(self, other: _object) -> _bool: ... + def __gt__(self, other: _object) -> _bool: ... + def __ge__(self, other: _object) -> _bool: ... def __repr__(self) -> _str: ... Relative: _typing.TypeAlias = '_TrackAnchor_Relative' Oldest: _typing.TypeAlias = '_TrackAnchor_Oldest' @@ -1775,6 +1815,10 @@ class Level(_enum.Enum): INFO = 2 WARN = 3 ERROR = 4 + def __lt__(self, other: _object) -> _bool: ... + def __le__(self, other: _object) -> _bool: ... + def __gt__(self, other: _object) -> _bool: ... + def __ge__(self, other: _object) -> _bool: ... def __str__(self) -> _str: ... class Park(_n.Object): def __repr__(self) -> _str: ... @@ -1815,6 +1859,10 @@ class Driver(_n.Object): def poll(self, now: ClockInstant, waiter: Waiter) -> ClockInstant | None: ... class Instance(_n.Object): def __eq__(self, other: _object) -> _bool: ... + def __lt__(self, other: _object) -> _bool: ... + def __le__(self, other: _object) -> _bool: ... + def __gt__(self, other: _object) -> _bool: ... + def __ge__(self, other: _object) -> _bool: ... def __str__(self) -> _str: ... def __repr__(self) -> _str: ... def clone(self) -> Instance: ... @@ -1825,6 +1873,10 @@ class Instance(_n.Object): def is_minted(self) -> _bool: ... class Path(_n.Object): def __eq__(self, other: _object) -> _bool: ... + def __lt__(self, other: _object) -> _bool: ... + def __le__(self, other: _object) -> _bool: ... + def __gt__(self, other: _object) -> _bool: ... + def __ge__(self, other: _object) -> _bool: ... def __str__(self) -> _str: ... def __repr__(self) -> _str: ... def clone(self) -> Path: ... @@ -1849,6 +1901,10 @@ class Path(_n.Object): def relative(self, base: Path) -> PathRelative | None: ... class Pattern(_n.Object): def __eq__(self, other: _object) -> _bool: ... + def __lt__(self, other: _object) -> _bool: ... + def __le__(self, other: _object) -> _bool: ... + def __gt__(self, other: _object) -> _bool: ... + def __ge__(self, other: _object) -> _bool: ... def __str__(self) -> _str: ... def __repr__(self) -> _str: ... def clone(self) -> Pattern: ... @@ -1971,6 +2027,10 @@ class Error(_n.Object): def retry(self) -> Retry: ... class Timestamp(_n.Object): def __eq__(self, other: _object) -> _bool: ... + def __lt__(self, other: _object) -> _bool: ... + def __le__(self, other: _object) -> _bool: ... + def __gt__(self, other: _object) -> _bool: ... + def __ge__(self, other: _object) -> _bool: ... def __repr__(self) -> _str: ... def clone(self) -> Timestamp: ... def __hash__(self) -> _int: ... @@ -2027,6 +2087,10 @@ class Versions(_n.Object): def iter(self) -> _list[Version]: ... class Specificity(_n.Object): def __eq__(self, other: _object) -> _bool: ... + def __lt__(self, other: _object) -> _bool: ... + def __le__(self, other: _object) -> _bool: ... + def __gt__(self, other: _object) -> _bool: ... + def __ge__(self, other: _object) -> _bool: ... def __repr__(self) -> _str: ... def clone(self) -> Specificity: ... def __hash__(self) -> _int: ... @@ -2317,6 +2381,10 @@ class MuxError(_n.Object): def clone(self) -> MuxError: ... class TokioDuration(_n.Object): def __eq__(self, other: _object) -> _bool: ... + def __lt__(self, other: _object) -> _bool: ... + def __le__(self, other: _object) -> _bool: ... + def __gt__(self, other: _object) -> _bool: ... + def __ge__(self, other: _object) -> _bool: ... def __str__(self) -> _str: ... def __repr__(self) -> _str: ... def clone(self) -> TokioDuration: ... @@ -7891,6 +7959,10 @@ class MoqSockDemuxPin(_n.Object): def __repr__(self) -> _str: ... class Url(_n.Object): def __eq__(self, other: _object) -> _bool: ... + def __lt__(self, other: _object) -> _bool: ... + def __le__(self, other: _object) -> _bool: ... + def __gt__(self, other: _object) -> _bool: ... + def __ge__(self, other: _object) -> _bool: ... def __str__(self) -> _str: ... def __repr__(self) -> _str: ... def clone(self) -> Url: ... @@ -7903,6 +7975,10 @@ class Json(_n.Object): def to_text(self) -> _str: ... class Instant(_n.Object): def __eq__(self, other: _object) -> _bool: ... + def __lt__(self, other: _object) -> _bool: ... + def __le__(self, other: _object) -> _bool: ... + def __gt__(self, other: _object) -> _bool: ... + def __ge__(self, other: _object) -> _bool: ... def __repr__(self) -> _str: ... def clone(self) -> Instant: ... def __hash__(self) -> _int: ... diff --git a/ffi/surface/moq/swift.swift b/ffi/surface/moq/swift.swift index 3c524d1db..5b5137f91 100644 --- a/ffi/surface/moq/swift.swift +++ b/ffi/surface/moq/swift.swift @@ -261,10 +261,14 @@ public struct TimeOverflow: Sendable, CustomStringConvertible, CustomDebugString @inlinable public var debugDescription: Swift.String { get } @inlinable public static func == (a: TimeOverflow, b: TimeOverflow) -> Swift.Bool } -public struct Timescale: Sendable, CustomStringConvertible, CustomDebugStringConvertible, Hashable { +public struct Timescale: Sendable, CustomStringConvertible, CustomDebugStringConvertible, Hashable, Comparable { @inlinable public var description: Swift.String { get } @inlinable public var debugDescription: Swift.String { get } @inlinable public static func == (a: Timescale, b: Timescale) -> Swift.Bool + @inlinable public static func < (a: Timescale, b: Timescale) -> Swift.Bool + @inlinable public static func <= (a: Timescale, b: Timescale) -> Swift.Bool + @inlinable public static func > (a: Timescale, b: Timescale) -> Swift.Bool + @inlinable public static func >= (a: Timescale, b: Timescale) -> Swift.Bool @inlinable public func hash(into hasher: inout Swift.Hasher) @inlinable public static var SECOND: Timescale { get } @inlinable public static var MILLI: Timescale { get } @@ -273,9 +277,13 @@ public struct Timescale: Sendable, CustomStringConvertible, CustomDebugStringCon @inlinable public static func new(_ unitsPerSecond: Swift.UInt64) throws -> Timescale @inlinable public func asU64() -> Swift.UInt64 } -public struct ClockInstant: Sendable, CustomDebugStringConvertible, Hashable { +public struct ClockInstant: Sendable, CustomDebugStringConvertible, Hashable, Comparable { @inlinable public var debugDescription: Swift.String { get } @inlinable public static func == (a: ClockInstant, b: ClockInstant) -> Swift.Bool + @inlinable public static func < (a: ClockInstant, b: ClockInstant) -> Swift.Bool + @inlinable public static func <= (a: ClockInstant, b: ClockInstant) -> Swift.Bool + @inlinable public static func > (a: ClockInstant, b: ClockInstant) -> Swift.Bool + @inlinable public static func >= (a: ClockInstant, b: ClockInstant) -> Swift.Bool @inlinable public func hash(into hasher: inout Swift.Hasher) @inlinable public static var ZERO: ClockInstant { get } @inlinable public static func now() -> ClockInstant @@ -295,9 +303,13 @@ public struct ClockElapsed: Sendable, CustomStringConvertible, CustomDebugString @inlinable public var debugDescription: Swift.String { get } @inlinable public static func == (a: ClockElapsed, b: ClockElapsed) -> Swift.Bool } -public struct ClockWall: Sendable, CustomDebugStringConvertible, Hashable { +public struct ClockWall: Sendable, CustomDebugStringConvertible, Hashable, Comparable { @inlinable public var debugDescription: Swift.String { get } @inlinable public static func == (a: ClockWall, b: ClockWall) -> Swift.Bool + @inlinable public static func < (a: ClockWall, b: ClockWall) -> Swift.Bool + @inlinable public static func <= (a: ClockWall, b: ClockWall) -> Swift.Bool + @inlinable public static func > (a: ClockWall, b: ClockWall) -> Swift.Bool + @inlinable public static func >= (a: ClockWall, b: ClockWall) -> Swift.Bool @inlinable public func hash(into hasher: inout Swift.Hasher) @inlinable public static var UNIXEPOCH: ClockWall { get } @inlinable public static var MOQEPOCH: ClockWall { get } @@ -531,9 +543,13 @@ public struct StatsWithdrawals: Sendable, CustomDebugStringConvertible, Equatabl @inlinable public mutating func add(_ other: StatsWithdrawals) @inlinable public func regressed(_ previous: StatsWithdrawals) -> Swift.Bool } -public struct BandwidthRate: Sendable, CustomDebugStringConvertible, Hashable { +public struct BandwidthRate: Sendable, CustomDebugStringConvertible, Hashable, Comparable { @inlinable public var debugDescription: Swift.String { get } @inlinable public static func == (a: BandwidthRate, b: BandwidthRate) -> Swift.Bool + @inlinable public static func < (a: BandwidthRate, b: BandwidthRate) -> Swift.Bool + @inlinable public static func <= (a: BandwidthRate, b: BandwidthRate) -> Swift.Bool + @inlinable public static func > (a: BandwidthRate, b: BandwidthRate) -> Swift.Bool + @inlinable public static func >= (a: BandwidthRate, b: BandwidthRate) -> Swift.Bool @inlinable public func hash(into hasher: inout Swift.Hasher) @inlinable public static func `default`() -> BandwidthRate @inlinable public static var ZERO: BandwidthRate { get } @@ -558,11 +574,15 @@ public struct FrameInfo: Sendable { @inlinable public init(size: Swift.UInt64, timestamp: Timestamp) @inlinable public var debugDescription: Swift.String { get } } -public struct GroupInfo: Sendable, CustomDebugStringConvertible, Hashable { +public struct GroupInfo: Sendable, CustomDebugStringConvertible, Hashable, Comparable { public var start: Swift.UInt64 @inlinable public init(start: Swift.UInt64) @inlinable public var debugDescription: Swift.String { get } @inlinable public static func == (a: GroupInfo, b: GroupInfo) -> Swift.Bool + @inlinable public static func < (a: GroupInfo, b: GroupInfo) -> Swift.Bool + @inlinable public static func <= (a: GroupInfo, b: GroupInfo) -> Swift.Bool + @inlinable public static func > (a: GroupInfo, b: GroupInfo) -> Swift.Bool + @inlinable public static func >= (a: GroupInfo, b: GroupInfo) -> Swift.Bool @inlinable public func hash(into hasher: inout Swift.Hasher) } public struct TrackDelay: Sendable, CustomDebugStringConvertible, Equatable { @@ -575,9 +595,13 @@ public struct TrackDelay: Sendable, CustomDebugStringConvertible, Equatable { @inlinable public func withMin(_ min: RustDuration?) -> TrackDelay @inlinable public func withMax(_ max: RustDuration?) -> TrackDelay } -public struct TrackPosition: Sendable, CustomDebugStringConvertible, Hashable { +public struct TrackPosition: Sendable, CustomDebugStringConvertible, Hashable, Comparable { @inlinable public var debugDescription: Swift.String { get } @inlinable public static func == (a: TrackPosition, b: TrackPosition) -> Swift.Bool + @inlinable public static func < (a: TrackPosition, b: TrackPosition) -> Swift.Bool + @inlinable public static func <= (a: TrackPosition, b: TrackPosition) -> Swift.Bool + @inlinable public static func > (a: TrackPosition, b: TrackPosition) -> Swift.Bool + @inlinable public static func >= (a: TrackPosition, b: TrackPosition) -> Swift.Bool @inlinable public func hash(into hasher: inout Swift.Hasher) @inlinable public static func `default`() -> TrackPosition @inlinable public var groupGet: Swift.UInt64 { get } @@ -587,26 +611,38 @@ public struct TrackPosition: Sendable, CustomDebugStringConvertible, Hashable { @inlinable public static func new(_ group: Swift.UInt64, _ frame: Swift.UInt64) -> TrackPosition @inlinable public static func group(_ group: Swift.UInt64) -> TrackPosition } -public struct TrackRange: Sendable, CustomDebugStringConvertible, Hashable { +public struct TrackRange: Sendable, CustomDebugStringConvertible, Hashable, Comparable { public var start: TrackAnchor public var end: TrackAnchor? @inlinable public init(start: TrackAnchor, end: TrackAnchor?) @inlinable public var debugDescription: Swift.String { get } @inlinable public static func == (a: TrackRange, b: TrackRange) -> Swift.Bool + @inlinable public static func < (a: TrackRange, b: TrackRange) -> Swift.Bool + @inlinable public static func <= (a: TrackRange, b: TrackRange) -> Swift.Bool + @inlinable public static func > (a: TrackRange, b: TrackRange) -> Swift.Bool + @inlinable public static func >= (a: TrackRange, b: TrackRange) -> Swift.Bool @inlinable public func hash(into hasher: inout Swift.Hasher) @inlinable public static func live() -> TrackRange @inlinable public static func oldest() -> TrackRange } -public struct OriginCost: Sendable, CustomDebugStringConvertible, Equatable { +public struct OriginCost: Sendable, CustomDebugStringConvertible, Equatable, Comparable { @inlinable public var debugDescription: Swift.String { get } @inlinable public static func == (a: OriginCost, b: OriginCost) -> Swift.Bool + @inlinable public static func < (a: OriginCost, b: OriginCost) -> Swift.Bool + @inlinable public static func <= (a: OriginCost, b: OriginCost) -> Swift.Bool + @inlinable public static func > (a: OriginCost, b: OriginCost) -> Swift.Bool + @inlinable public static func >= (a: OriginCost, b: OriginCost) -> Swift.Bool @inlinable public static func `default`() -> OriginCost @inlinable public static func new(_ cost: Swift.UInt64) -> OriginCost @inlinable public func value() -> Swift.UInt64 } -public struct OriginPriority: Sendable, CustomDebugStringConvertible, Hashable { +public struct OriginPriority: Sendable, CustomDebugStringConvertible, Hashable, Comparable { @inlinable public var debugDescription: Swift.String { get } @inlinable public static func == (a: OriginPriority, b: OriginPriority) -> Swift.Bool + @inlinable public static func < (a: OriginPriority, b: OriginPriority) -> Swift.Bool + @inlinable public static func <= (a: OriginPriority, b: OriginPriority) -> Swift.Bool + @inlinable public static func > (a: OriginPriority, b: OriginPriority) -> Swift.Bool + @inlinable public static func >= (a: OriginPriority, b: OriginPriority) -> Swift.Bool @inlinable public func hash(into hasher: inout Swift.Hasher) @inlinable public static func `default`() -> OriginPriority @inlinable public static func new(_ priority: Swift.Int8) -> OriginPriority @@ -1126,12 +1162,16 @@ public enum TrackCompression: Sendable, CustomDebugStringConvertible, Hashable { @inlinable public func hash(into hasher: inout Swift.Hasher) @inlinable public static func `default`() -> TrackCompression } -public enum TrackAnchor: Sendable, CustomDebugStringConvertible, Hashable { +public enum TrackAnchor: Sendable, CustomDebugStringConvertible, Hashable, Comparable { case relative(Swift.UInt64) case oldest case time(Swift.UInt64) @inlinable public var debugDescription: Swift.String { get } @inlinable public static func == (a: TrackAnchor, b: TrackAnchor) -> Swift.Bool + @inlinable public static func < (a: TrackAnchor, b: TrackAnchor) -> Swift.Bool + @inlinable public static func <= (a: TrackAnchor, b: TrackAnchor) -> Swift.Bool + @inlinable public static func > (a: TrackAnchor, b: TrackAnchor) -> Swift.Bool + @inlinable public static func >= (a: TrackAnchor, b: TrackAnchor) -> Swift.Bool @inlinable public func hash(into hasher: inout Swift.Hasher) } public enum TrackOrder: Sendable, CustomDebugStringConvertible, Hashable { @@ -1585,7 +1625,7 @@ public enum MoqSockUdpEcnCodepoint: Sendable, CustomDebugStringConvertible, Equa @inlinable public static func == (a: MoqSockUdpEcnCodepoint, b: MoqSockUdpEcnCodepoint) -> Swift.Bool @inlinable public static func fromBits(_ x: Swift.UInt8) -> MoqSockUdpEcnCodepoint? } -public enum Level: Sendable, CustomStringConvertible, Hashable { +public enum Level: Sendable, CustomStringConvertible, Hashable, Comparable { case trace case debug case info @@ -1593,6 +1633,10 @@ public enum Level: Sendable, CustomStringConvertible, Hashable { case error @inlinable public var description: Swift.String { get } @inlinable public static func == (a: Level, b: Level) -> Swift.Bool + @inlinable public static func < (a: Level, b: Level) -> Swift.Bool + @inlinable public static func <= (a: Level, b: Level) -> Swift.Bool + @inlinable public static func > (a: Level, b: Level) -> Swift.Bool + @inlinable public static func >= (a: Level, b: Level) -> Swift.Bool @inlinable public func hash(into hasher: inout Swift.Hasher) } public struct Park: ~Copyable, @unchecked Sendable { @@ -1635,6 +1679,10 @@ public struct Instance: ~Copyable, @unchecked Sendable { @inlinable public var debugDescription: Swift.String { get } @inlinable public func clone() throws -> Instance @inlinable public static func == (a: borrowing Instance, b: borrowing Instance) throws -> Swift.Bool + @inlinable public static func < (a: borrowing Instance, b: borrowing Instance) throws -> Swift.Bool + @inlinable public static func <= (a: borrowing Instance, b: borrowing Instance) throws -> Swift.Bool + @inlinable public static func > (a: borrowing Instance, b: borrowing Instance) throws -> Swift.Bool + @inlinable public static func >= (a: borrowing Instance, b: borrowing Instance) throws -> Swift.Bool @inlinable public func hash(into hasher: inout Swift.Hasher) throws @inlinable public static func random() -> Instance @inlinable public func asStr() throws -> Swift.String @@ -1645,6 +1693,10 @@ public struct Path: ~Copyable, @unchecked Sendable { @inlinable public var debugDescription: Swift.String { get } @inlinable public func clone() throws -> Path @inlinable public static func == (a: borrowing Path, b: borrowing Path) throws -> Swift.Bool + @inlinable public static func < (a: borrowing Path, b: borrowing Path) throws -> Swift.Bool + @inlinable public static func <= (a: borrowing Path, b: borrowing Path) throws -> Swift.Bool + @inlinable public static func > (a: borrowing Path, b: borrowing Path) throws -> Swift.Bool + @inlinable public static func >= (a: borrowing Path, b: borrowing Path) throws -> Swift.Bool @inlinable public func hash(into hasher: inout Swift.Hasher) throws @inlinable public static func `default`() -> Path @inlinable public static func new(_ s: Swift.String) throws -> Path @@ -1666,6 +1718,10 @@ public struct Pattern: ~Copyable, @unchecked Sendable { @inlinable public var debugDescription: Swift.String { get } @inlinable public func clone() throws -> Pattern @inlinable public static func == (a: borrowing Pattern, b: borrowing Pattern) throws -> Swift.Bool + @inlinable public static func < (a: borrowing Pattern, b: borrowing Pattern) throws -> Swift.Bool + @inlinable public static func <= (a: borrowing Pattern, b: borrowing Pattern) throws -> Swift.Bool + @inlinable public static func > (a: borrowing Pattern, b: borrowing Pattern) throws -> Swift.Bool + @inlinable public static func >= (a: borrowing Pattern, b: borrowing Pattern) throws -> Swift.Bool @inlinable public func hash(into hasher: inout Swift.Hasher) throws @inlinable public static func `default`() -> Pattern @inlinable public static func new(_ segments: [Segment]) throws -> Pattern @@ -1780,6 +1836,10 @@ public final class Timestamp: @unchecked Sendable { @inlinable public var debugDescription: Swift.String { get } @inlinable public func clone() throws -> Timestamp @inlinable public static func == (a: Timestamp, b: Timestamp) throws -> Swift.Bool + @inlinable public static func < (a: Timestamp, b: Timestamp) throws -> Swift.Bool + @inlinable public static func <= (a: Timestamp, b: Timestamp) throws -> Swift.Bool + @inlinable public static func > (a: Timestamp, b: Timestamp) throws -> Swift.Bool + @inlinable public static func >= (a: Timestamp, b: Timestamp) throws -> Swift.Bool @inlinable public func hash(into hasher: inout Swift.Hasher) throws @inlinable public static var ZERO: Timestamp { get } @inlinable public static func new(_ value: Swift.UInt64, _ scale: Timescale) throws -> Timestamp @@ -1824,10 +1884,14 @@ public struct Versions: ~Copyable, @unchecked Sendable { @inlinable public func contains(_ version: Version) throws -> Swift.Bool @inlinable public func iter() throws -> [Version] } -public final class Specificity: @unchecked Sendable, CustomDebugStringConvertible, Hashable { +public final class Specificity: @unchecked Sendable, CustomDebugStringConvertible, Hashable, Comparable { @inlinable public var debugDescription: Swift.String { get } @inlinable public func clone() -> Specificity @inlinable public static func == (a: Specificity, b: Specificity) -> Swift.Bool + @inlinable public static func < (a: Specificity, b: Specificity) -> Swift.Bool + @inlinable public static func <= (a: Specificity, b: Specificity) -> Swift.Bool + @inlinable public static func > (a: Specificity, b: Specificity) -> Swift.Bool + @inlinable public static func >= (a: Specificity, b: Specificity) -> Swift.Bool @inlinable public func hash(into hasher: inout Swift.Hasher) } public struct ClockClock: ~Copyable, @unchecked Sendable { @@ -2081,11 +2145,15 @@ public final class MuxError: @unchecked Sendable, CustomStringConvertible, Custo @inlinable public var debugDescription: Swift.String { get } @inlinable public func clone() -> MuxError } -public final class TokioDuration: @unchecked Sendable, CustomStringConvertible, CustomDebugStringConvertible, Hashable { +public final class TokioDuration: @unchecked Sendable, CustomStringConvertible, CustomDebugStringConvertible, Hashable, Comparable { @inlinable public var description: Swift.String { get } @inlinable public var debugDescription: Swift.String { get } @inlinable public func clone() -> TokioDuration @inlinable public static func == (a: TokioDuration, b: TokioDuration) -> Swift.Bool + @inlinable public static func < (a: TokioDuration, b: TokioDuration) -> Swift.Bool + @inlinable public static func <= (a: TokioDuration, b: TokioDuration) -> Swift.Bool + @inlinable public static func > (a: TokioDuration, b: TokioDuration) -> Swift.Bool + @inlinable public static func >= (a: TokioDuration, b: TokioDuration) -> Swift.Bool @inlinable public func hash(into hasher: inout Swift.Hasher) @inlinable public static func `default`() -> TokioDuration } @@ -7204,6 +7272,10 @@ public struct Url: ~Copyable, @unchecked Sendable { @inlinable public var debugDescription: Swift.String { get } @inlinable public func clone() throws -> Url @inlinable public static func == (a: borrowing Url, b: borrowing Url) throws -> Swift.Bool + @inlinable public static func < (a: borrowing Url, b: borrowing Url) throws -> Swift.Bool + @inlinable public static func <= (a: borrowing Url, b: borrowing Url) throws -> Swift.Bool + @inlinable public static func > (a: borrowing Url, b: borrowing Url) throws -> Swift.Bool + @inlinable public static func >= (a: borrowing Url, b: borrowing Url) throws -> Swift.Bool @inlinable public func hash(into hasher: inout Swift.Hasher) throws @inlinable public static func parse(_ input: Swift.String) throws -> Url } @@ -7211,10 +7283,14 @@ public struct Json: ~Copyable, @unchecked Sendable { @inlinable public static func parse(_ input: Swift.String) throws -> Json @inlinable public func toText() throws -> Swift.String } -public final class Instant: @unchecked Sendable, CustomDebugStringConvertible, Hashable { +public final class Instant: @unchecked Sendable, CustomDebugStringConvertible, Hashable, Comparable { @inlinable public var debugDescription: Swift.String { get } @inlinable public func clone() -> Instant @inlinable public static func == (a: Instant, b: Instant) -> Swift.Bool + @inlinable public static func < (a: Instant, b: Instant) -> Swift.Bool + @inlinable public static func <= (a: Instant, b: Instant) -> Swift.Bool + @inlinable public static func > (a: Instant, b: Instant) -> Swift.Bool + @inlinable public static func >= (a: Instant, b: Instant) -> Swift.Bool @inlinable public func hash(into hasher: inout Swift.Hasher) } public struct RustlsServerConfig: ~Copyable, @unchecked Sendable { diff --git a/ffi/surface/surface.py b/ffi/surface/surface.py index bf7cb6ccd..e56001a04 100644 --- a/ffi/surface/surface.py +++ b/ffi/surface/surface.py @@ -190,7 +190,8 @@ def assignment(masked): k = m.start() if k in top and not re.search(r"\boperator\s*\S*$", masked[:k]): return k - for m in re.finditer(r"=>", masked): + # Dart's expression body, not C++'s `operator<=>`. + for m in re.finditer(r"(?", masked): if m.start() in top: return m.start() return None diff --git a/ffi/surface/test_surface.py b/ffi/surface/test_surface.py index 62cebcb93..6aa574510 100644 --- a/ffi/surface/test_surface.py +++ b/ffi/surface/test_surface.py @@ -193,6 +193,7 @@ class Marker { return {}; } inline bool operator==(const Marker &a, const Marker &b) { return true; } +inline ::std::weak_ordering operator<=>(const Marker &a, const Marker &b) { return a.n <=> b.n; } } // namespace api """ self.assertEqual(self.outline(source), [ @@ -214,6 +215,7 @@ class Marker { "\t\ttemplate > void each(F f) const;", "\t};", "\tinline bool operator==(const Marker &a, const Marker &b);", + "\tinline ::std::weak_ordering operator<=>(const Marker &a, const Marker &b);", "}", ]) diff --git a/ffi/tests/fixtures/transcript/c.rs b/ffi/tests/fixtures/transcript/c.rs index 1472549f2..b4f8613ce 100644 --- a/ffi/tests/fixtures/transcript/c.rs +++ b/ffi/tests/fixtures/transcript/c.rs @@ -1369,25 +1369,27 @@ impl Emitter<'_> { } let (a, b) = (self.expr(a), self.expr(b)); let operand = unref(&a.ty).base().clone(); + // A value of the API compares through its C function, a record or an enum by address. + let by_address = match &operand { + Type::Record(_) | Type::Enum(_) => Some(true), + Type::Object(_) => Some(false), + _ => None, + }; + let compare = |s: &mut Self, suffix: &str, ty: &Type| { + let by_address = by_address.expect("a value of the API"); + let name = format!("{}_{suffix}", s.type_name(&operand)); + let (a, b) = match by_address { + true => (s.place(a.clone()), s.place(b.clone())), + false => (a.clone(), b.clone()), + }; + let amp = if by_address { "&" } else { "" }; + let call = s.invoke(&name, vec![format!("{amp}{}", a.c), format!("{amp}{}", b.c)]); + s.bound(call, ty).c + }; let c = match op { Op::Eq | Op::Ne => { - let equal = match &operand { - Type::Record(_) => Some(true), - Type::Enum(_) => Some(true), - Type::Object(_) => Some(false), - _ => None, - }; - let eq = match equal { - Some(by_address) => { - let name = format!("{}_eq", self.type_name(&operand)); - let (a, b) = match by_address { - true => (self.place(a), self.place(b)), - false => (a, b), - }; - let amp = if by_address { "&" } else { "" }; - let call = self.invoke(&name, vec![format!("{amp}{}", a.c), format!("{amp}{}", b.c)]); - self.bound(call, &Type::Bool).c - } + let eq = match by_address { + Some(_) => compare(self, "eq", &Type::Bool), None => format!("({} == {})", a.c, b.c), }; match op { @@ -1395,8 +1397,21 @@ impl Emitter<'_> { _ => format!("(!{eq})"), } } + // `partial_cmp` is -1, 0, 1, or 2 when unordered. + Op::Lt | Op::Le | Op::Gt | Op::Ge if by_address.is_some() => { + let r = compare(self, "partial_cmp", &Type::Int(Int::I8)); + match op { + Op::Lt => format!("({r} == -1)"), + Op::Le => format!("({r} == -1 || {r} == 0)"), + Op::Gt => format!("({r} == 1)"), + _ => format!("({r} == 0 || {r} == 1)"), + } + } + Op::Cmp => compare(self, "cmp", &Type::Int(Int::I8)), Op::Lt => format!("({} < {})", a.c, b.c), + Op::Le => format!("({} <= {})", a.c, b.c), Op::Gt => format!("({} > {})", a.c, b.c), + Op::Ge => format!("({} >= {})", a.c, b.c), Op::Add | Op::Sub | Op::Mul | Op::Rem => { let symbol = match op { Op::Add => "+", diff --git a/ffi/tests/fixtures/transcript/cpp.rs b/ffi/tests/fixtures/transcript/cpp.rs index 0c4e7bff5..9e47d04c0 100644 --- a/ffi/tests/fixtures/transcript/cpp.rs +++ b/ffi/tests/fixtures/transcript/cpp.rs @@ -68,6 +68,18 @@ inline std::string flag(bool value) { return value ? "true" : "false"; } +// Rust's `Ord` of two values: through `<=>` from C++20, which calls `cmp`, and before it +// through `<`, which calls `partial_cmp`. +template +std::int8_t cmp(const T &a, const T &b) { +#if defined(__cpp_lib_three_way_comparison) + auto order = a <=> b; + return order < 0 ? -1 : order > 0 ? 1 : 0; +#else + return a < b ? -1 : b < a ? 1 : 0; +#endif +} + // Zeros before `digits` up to `width`. inline std::string pad(std::string digits, int width) { if (static_cast(digits.size()) < width) { @@ -1203,10 +1215,13 @@ impl Emitter<'_> { Kind::Binary(op, a, b) => { let (a, b) = (self.value(a, &a.ty, Place::Read), self.value(b, &b.ty, Place::Read)); let (op, arithmetic) = match op { + Op::Cmp => return format!("rs::cmp({a}, {b})"), Op::Eq => ("==", false), Op::Ne => ("!=", false), Op::Lt => ("<", false), + Op::Le => ("<=", false), Op::Gt => (">", false), + Op::Ge => (">=", false), Op::And => ("&&", false), Op::Add => ("+", true), Op::Sub => ("-", true), diff --git a/ffi/tests/fixtures/transcript/dart.rs b/ffi/tests/fixtures/transcript/dart.rs index bcba5d16b..1e4b88e3b 100644 --- a/ffi/tests/fixtures/transcript/dart.rs +++ b/ffi/tests/fixtures/transcript/dart.rs @@ -993,7 +993,10 @@ impl Emitter<'_> { Op::Eq => compare("=="), Op::Ne => compare("!="), Op::Lt => compare("<"), + Op::Le => compare("<="), Op::Gt => compare(">"), + Op::Ge => compare(">="), + Op::Cmp => format!("{a}.compareTo({b})"), Op::And => compare("&&"), Op::Add | Op::Sub | Op::Mul | Op::Rem => { let Type::Int(int) = unref(ty).base() else { diff --git a/ffi/tests/fixtures/transcript/go.rs b/ffi/tests/fixtures/transcript/go.rs index cc80fadef..09637fd47 100644 --- a/ffi/tests/fixtures/transcript/go.rs +++ b/ffi/tests/fixtures/transcript/go.rs @@ -1381,8 +1381,46 @@ impl Emitter<'_> { ty => panic!("== of {ty:?}"), } } + // A value of the API orders through `PartialCompare`, whose false is unordered, and + // with `Ord` through `Compare`. + Op::Lt | Op::Le | Op::Gt | Op::Ge | Op::Cmp + if matches!(ty, Type::Record(_) | Type::Enum(_) | Type::Object(_)) => + { + self.lent(&x); + self.lent(&y); + let fails = matches!(ty, Type::Object(_)) || fails(self.t, &ty); + if op == Op::Cmp { + let made = self.hoist( + &format!("{x}.Compare({y})"), + &[Type::Int(Int::I8)], + fails, + Failure::Panic, + true, + out, + ); + return made.values[0].clone(); + } + let made = self.hoist( + &format!("{x}.PartialCompare({y})"), + &[Type::Int(Int::I8), Type::Bool], + fails, + Failure::Panic, + true, + out, + ); + let sym = match op { + Op::Lt => "<", + Op::Le => "<=", + Op::Gt => ">", + _ => ">=", + }; + format!("({} && {} {sym} 0)", made.values[1], made.values[0]) + } Op::Lt => format!("({x} < {y})"), + Op::Le => format!("({x} <= {y})"), Op::Gt => format!("({x} > {y})"), + Op::Ge => format!("({x} >= {y})"), + Op::Cmp => unreachable!("`cmp` of a value of the API"), Op::Add | Op::Sub | Op::Mul | Op::Rem => { let Type::Int(_) = ty else { panic!("arithmetic on {ty:?}") diff --git a/ffi/tests/fixtures/transcript/ir.rs b/ffi/tests/fixtures/transcript/ir.rs index d455b1d76..6243f1ba7 100644 --- a/ffi/tests/fixtures/transcript/ir.rs +++ b/ffi/tests/fixtures/transcript/ir.rs @@ -31,6 +31,16 @@ impl Api { on & all == all } + /// The std traits of `ty`, a record, an enum, or an object. + pub(crate) fn traits(&self, ty: &Type) -> Option { + match ty { + Type::Record(i) => Some(self.records[*i].traits), + Type::Enum(i) => Some(self.enums[*i].traits), + Type::Object(i) => Some(self.objects[*i].traits), + _ => None, + } + } + /// The objects a value of `ty` holds, its records' and enums' fields included. pub(crate) fn handles(&self, ty: &Type, out: &mut Vec, seen: &mut Vec<(bool, usize)>) { match ty { @@ -133,6 +143,17 @@ pub(crate) struct Traits { pub(crate) clone: bool, pub(crate) display: bool, pub(crate) debug: bool, + #[serde(default)] + pub(crate) ord: Order, +} + +/// How a type orders its values: by `PartialOrd`, and whether `Ord` too. +#[derive(Clone, Copy, Default, PartialEq, Eq, Debug, serde::Deserialize)] +pub(crate) enum Order { + #[default] + None, + Partial, + Total, } #[derive(serde::Deserialize)] diff --git a/ffi/tests/fixtures/transcript/kotlin.rs b/ffi/tests/fixtures/transcript/kotlin.rs index 6766c333d..c349ced83 100644 --- a/ffi/tests/fixtures/transcript/kotlin.rs +++ b/ffi/tests/fixtures/transcript/kotlin.rs @@ -3,7 +3,7 @@ use std::fmt::Write; -use super::ir::{Access, Collection, Int, Mutability, Receiver, Type}; +use super::ir::{Access, Collection, Int, Mutability, Order, Receiver, Type}; use super::{ Arm, BoundKind, Expr, FnId, Kind, Num, Op, Owner, Pat, Piece, Spec, Step, Transcript, each_expr, unref, walk, }; @@ -693,11 +693,25 @@ impl Emitter<'_> { Kind::Binary(op, a, b) => { let ty = unref(&a.ty).base().clone(); let (a, b) = (self.value(a, &ty, out), self.value(b, &ty, out)); + // A partial order has no `compareTo`, only `partialCompareTo`, null when unordered. + if self.t.api.traits(&ty).is_some_and(|t| t.ord == Order::Partial) + && let Some(test) = match op { + Op::Lt => Some("it == -1"), + Op::Le => Some("it <= 0"), + Op::Gt => Some("it == 1"), + Op::Ge => Some("it >= 0"), + _ => None, + } { + return format!("({a}.partialCompareTo({b})?.let {{ {test} }} ?: false)"); + } let sym = match op { + Op::Cmp => return format!("Integer.signum({a}.compareTo({b})).toByte()"), Op::Eq => "==", Op::Ne => "!=", Op::Lt => "<", + Op::Le => "<=", Op::Gt => ">", + Op::Ge => ">=", Op::Add => "+", Op::Sub => "-", Op::Mul => "*", diff --git a/ffi/tests/fixtures/transcript/mod.rs b/ffi/tests/fixtures/transcript/mod.rs index 11b8d425e..56515c861 100644 --- a/ffi/tests/fixtures/transcript/mod.rs +++ b/ffi/tests/fixtures/transcript/mod.rs @@ -149,7 +149,11 @@ pub(crate) enum Op { Eq, Ne, Lt, + Le, Gt, + Ge, + /// `a.cmp(&b) as i8`: Rust's `Ord`, -1, 0, or 1. + Cmp, Add, Sub, Mul, diff --git a/ffi/tests/fixtures/transcript/parse.rs b/ffi/tests/fixtures/transcript/parse.rs index ef717dbc4..7fa21bc45 100644 --- a/ffi/tests/fixtures/transcript/parse.rs +++ b/ffi/tests/fixtures/transcript/parse.rs @@ -767,6 +767,7 @@ impl Scope<'_> { syn::Expr::Field(f) => self.field(f), syn::Expr::Struct(s) => self.structure(s, None), syn::Expr::Binary(b) => self.binary(b), + syn::Expr::Cast(c) => self.ordering(c), syn::Expr::Macro(m) if m.mac.path.is_ident("format") => { Expr::new(Kind::Format(self.format(&m.mac)), Type::String) } @@ -1240,7 +1241,9 @@ impl Scope<'_> { syn::BinOp::Eq(_) => Op::Eq, syn::BinOp::Ne(_) => Op::Ne, syn::BinOp::Lt(_) => Op::Lt, + syn::BinOp::Le(_) => Op::Le, syn::BinOp::Gt(_) => Op::Gt, + syn::BinOp::Ge(_) => Op::Ge, syn::BinOp::Add(_) => Op::Add, syn::BinOp::Sub(_) => Op::Sub, syn::BinOp::Mul(_) => Op::Mul, @@ -1262,12 +1265,31 @@ impl Scope<'_> { } }; let ty = match op { - Op::Eq | Op::Ne | Op::Lt | Op::Gt | Op::And => Type::Bool, + Op::Eq | Op::Ne | Op::Lt | Op::Le | Op::Gt | Op::Ge | Op::And => Type::Bool, + Op::Cmp => unreachable!("no operator is `cmp`"), _ => unref(&left.ty).clone(), }; Expr::new(Kind::Binary(op, Box::new(left), Box::new(right)), ty) } + /// `a.cmp(&b) as i8`: Rust's `Ord` of two values of the API, as an integer, since + /// `Ordering` itself is no type of the subset. + fn ordering(&mut self, c: &syn::ExprCast) -> Expr { + let syn::Expr::MethodCall(m) = &*c.expr else { + fail(c, "a cast of anything but `cmp`") + }; + if m.method != "cmp" || m.args.len() != 1 || !matches!(&*c.ty, syn::Type::Path(t) if t.path.is_ident("i8")) { + fail(c, "a cast of anything but `cmp` as i8"); + } + let a = self.infer(&m.receiver); + let want = unref(&a.ty).clone(); + if !matches!(want.base(), Type::Record(_) | Type::Enum(_) | Type::Object(_)) { + fail(c, "`cmp` of no type of the API"); + } + let b = self.check(&m.args[0], &want); + Expr::new(Kind::Binary(Op::Cmp, Box::new(a), Box::new(b)), Type::Int(Int::I8)) + } + fn field(&mut self, f: &syn::ExprField) -> Expr { let base = self.infer(&f.base); let owner = unref(&base.ty).base().clone(); diff --git a/ffi/tests/fixtures/transcript/python.rs b/ffi/tests/fixtures/transcript/python.rs index 8b50308e0..bd509d4c6 100644 --- a/ffi/tests/fixtures/transcript/python.rs +++ b/ffi/tests/fixtures/transcript/python.rs @@ -92,6 +92,11 @@ def _fails(call, exception): return False +def _cmp(a, b): + """Rust's `Ord` of two values, through the comparisons Python has.""" + return (a > b) - (a < b) + + def _f64(bits): return struct.unpack(" { Kind::Binary(op, a, b) => { let (a, b) = (self.expr(a, out), self.expr(b, out)); let op = match op { + Op::Cmp => return format!("_cmp({a}, {b})"), Op::Eq => "==", Op::Ne => "!=", Op::Lt => "<", + Op::Le => "<=", Op::Gt => ">", + Op::Ge => ">=", Op::Add => "+", Op::Sub => "-", Op::Mul => "*", diff --git a/ffi/tests/fixtures/transcript/swift.rs b/ffi/tests/fixtures/transcript/swift.rs index 87aa33315..9bae52314 100644 --- a/ffi/tests/fixtures/transcript/swift.rs +++ b/ffi/tests/fixtures/transcript/swift.rs @@ -107,6 +107,11 @@ func _fails(_: E.Type, _ body: () throws -> T) -> fatalError("\(error)") } } + +/// Rust's `Ord` of two values, through `Comparable`. +func _cmp(_ a: T, _ b: T) -> Swift.Int8 { + a < b ? -1 : b < a ? 1 : 0 +} "#; /// The Swift file of `t`'s script. @@ -1190,7 +1195,7 @@ impl Emitter<'_> { Kind::IsSome(inner) => format!("({} != nil)", self.expr(inner, out)), Kind::IsNone(inner) => format!("({} == nil)", self.expr(inner, out)), Kind::Binary(op, a, b) => { - if matches!(op, Op::Eq | Op::Ne) { + if matches!(op, Op::Eq | Op::Ne | Op::Lt | Op::Le | Op::Gt | Op::Ge | Op::Cmp) { let ty = unref(&a.ty).base(); if matches!(ty, Type::Record(_) | Type::Enum(_) | Type::Object(_)) { self.threw |= self.model.traits_throw(&self.t.api, ty); @@ -1198,10 +1203,13 @@ impl Emitter<'_> { } let (a, b) = (self.expr(a, out), self.expr(b, out)); let op = match op { + Op::Cmp => return format!("_cmp({a}, {b})"), Op::Eq => "==", Op::Ne => "!=", Op::Lt => "<", + Op::Le => "<=", Op::Gt => ">", + Op::Ge => ">=", Op::Add => "+", Op::Sub => "-", Op::Mul => "*", diff --git a/ffi/tests/fixtures/transcript/typescript.rs b/ffi/tests/fixtures/transcript/typescript.rs index b5bb74265..39a147f80 100644 --- a/ffi/tests/fixtures/transcript/typescript.rs +++ b/ffi/tests/fixtures/transcript/typescript.rs @@ -1107,10 +1107,28 @@ impl Emitter<'_> { Op::Eq => self.equal(&x, &y, &ty), Op::Ne => format!("!{}", self.equal(&x, &y, &ty)), Op::And => format!("({x} && {y})"), - Op::Lt | Op::Gt | Op::Add | Op::Sub | Op::Mul | Op::Rem => { + // A value of the API orders through its module's `partialCmp`, undefined when + // unordered, and with `Ord` its `cmp`. + Op::Lt | Op::Le | Op::Gt | Op::Ge | Op::Cmp + if matches!(ty, Type::Record(_) | Type::Enum(_) | Type::Object(_)) => + { + let module = self.module(&ty); + let partial = format!("{module}.partialCmp({x}, {y})"); + match op { + Op::Lt => format!("({partial} === -1)"), + Op::Le => format!("(({partial} ?? 1) <= 0)"), + Op::Gt => format!("({partial} === 1)"), + Op::Ge => format!("(({partial} ?? -1) >= 0)"), + _ => format!("{module}.cmp({x}, {y})"), + } + } + Op::Cmp => unreachable!("`cmp` of a value of the API"), + Op::Lt | Op::Le | Op::Gt | Op::Ge | Op::Add | Op::Sub | Op::Mul | Op::Rem => { let symbol = match op { Op::Lt => "<", + Op::Le => "<=", Op::Gt => ">", + Op::Ge => ">=", Op::Add => "+", Op::Sub => "-", Op::Mul => "*", @@ -1121,7 +1139,7 @@ impl Emitter<'_> { Some(_) => { let joined = format!("{} {symbol} {}", big(&x, &ty), big(&y, &ty)); match op { - Op::Lt | Op::Gt => format!("({joined})"), + Op::Lt | Op::Le | Op::Gt | Op::Ge => format!("({joined})"), _ => format!("rt.{}FromBig({joined})", wide(&ty).unwrap()), } } diff --git a/quest/m1/ffi-export/README.md b/quest/m1/ffi-export/README.md index fc718f74f..c9cb587f3 100644 --- a/quest/m1/ffi-export/README.md +++ b/quest/m1/ffi-export/README.md @@ -104,7 +104,7 @@ Decided with the maintainer on 2026-11-18, in the per-language audit: - ✅ Work that changes no generated API, or only adds to it, stays out of this epic, as decided on 2026-11-12: [proofs](/quest/m1/ffi-proofs/README.md), [speed](/quest/m1/ffi-speed/README.md), [rule cost](/quest/m1/ffi-rules/README.md), - [packaging](/quest/m1/ffi-packaging/README.md), [ordering](/quest/m1/ffi-ord.md), and + [packaging](/quest/m1/ffi-packaging/README.md), ordering (landed), and [stream adapters](/quest/m1/ffi-streams.md). - Dropped: a per-function contract in place of the whole-header hash, since moq links statically and the strict check is what fails loud; C layout `_Static_assert`s, since diff --git a/quest/m1/ffi-ord.md b/quest/m1/ffi-ord.md deleted file mode 100644 index 021efbb6a..000000000 --- a/quest/m1/ffi-ord.md +++ /dev/null @@ -1,21 +0,0 @@ -# [M] Export ordering - -## Goal - -A type's `PartialOrd` and `Ord` impls export in every binding: C gets a `_cmp` returning --1, 0, or 1, and `_partial_cmp` adding "unordered"; C++ gets `<` and, from C++20, `<=>`; -each other language its own comparison protocol (`Comparable`, `__lt__` and friends, -`compareTo`, `cmp.Compare`-shaped functions). The `api` fixture covers a total and a -partial order, and moq-net's `Timestamp` orders from every binding. - -## Plan - -Found by the 2026-11-18 language audit: `ir::Traits` (`ffi/src/ir.rs:404`) has no -ordering, so C and C++ cannot order moq's frame timestamps, whose `PartialOrd` is -hand-written (`rs/moq-net/src/model/time.rs:426` in moq-dev/moq). - -Decided with the maintainer on 2026-11-18: ✅ kept, outside the exporter epic since it only -adds API (rejected: dropping it). Recommended: a hand-written `PartialOrd` that is not a -total order exports only the partial comparison, never `Comparable`. - -Public API: added comparison in every binding. From 8ac52786d0d858fb010454ffad6d1dcc4dc9ab73 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Fri, 20 Nov 2026 01:16:11 -0800 Subject: [PATCH 3/9] fix(ffi): keep fields clear of comparison methods, and order throwing Ord types in Swift's transcript - Go: a data enum's variant fields clear the methods its traits add, as a record's do. - Dart: a field never takes compareTo or partialCompareTo, so gaining Ord renames none. - Kotlin: comparable() no longer takes holders()'s doc comment. - Transcript: cmp's operands go through the ordering check, and Swift's _cmp takes the type's own <, so a type whose comparisons throw orders too. - api fixture: Pass, a checked object with Ord, and Rank, a data enum whose fields are named as the comparison methods. Co-Authored-By: Claude Opus 5.5 --- ffi/fixtures/api/examples/transcript.rs | 10 ++ ffi/fixtures/api/src/lib.rs | 31 +++++++ ffi/src/dart.rs | 15 ++- ffi/src/go.rs | 72 +++++++++------ ffi/src/kotlin.rs | 4 +- ffi/surface/api/c.h | 61 ++++++++++++- ffi/surface/api/cpp.hpp | 116 ++++++++++++++++++++++++ ffi/surface/api/dart.dart | 96 +++++++++++++++++++- ffi/surface/api/go.txt | 32 +++++++ ffi/surface/api/kotlin.kt | 50 +++++++++- ffi/surface/api/python.pyi | 66 ++++++++++++++ ffi/surface/api/swift.swift | 69 +++++++++++++- ffi/surface/api/web.d.ts | 29 ++++++ ffi/surface/moq/c.h | 39 +++++++- ffi/tests/fixtures/transcript/parse.rs | 1 + ffi/tests/fixtures/transcript/swift.rs | 11 ++- 16 files changed, 659 insertions(+), 43 deletions(-) diff --git a/ffi/fixtures/api/examples/transcript.rs b/ffi/fixtures/api/examples/transcript.rs index 8e7e5980a..6d9b508d5 100644 --- a/ffi/fixtures/api/examples/transcript.rs +++ b/ffi/fixtures/api/examples/transcript.rs @@ -1032,6 +1032,16 @@ fn main() { Tier::High.cmp(&Tier::Low) as i8, Tier::Low.cmp(&Tier::High) as i8 ); + // A pass's handle is checked, so its comparisons can fail, yet it still orders by `Ord`. + let (t1, t2) = (api::Pass::new(1), api::Pass::new(2)); + println!( + "pass {} {} {} {} {}", + t1 < t2, + t1 >= t2, + t1.cmp(&t2) as i8, + t2.cmp(&t1) as i8, + t1.cmp(&t1) as i8 + ); println!( "lossless ip {} {}", ip_hex(api::same_ip_addr("255.255.255.255".parse().unwrap())), diff --git a/ffi/fixtures/api/src/lib.rs b/ffi/fixtures/api/src/lib.rs index f0f301aa9..9ea50709d 100644 --- a/ffi/fixtures/api/src/lib.rs +++ b/ffi/fixtures/api/src/lib.rs @@ -5117,6 +5117,37 @@ impl PartialOrd for Quantity { } } +/// A pass: an object whose derived `Ord` is a total order, and whose handle a call checks, +/// since `redeem` moves it out. +#[derive(Debug, PartialEq, Eq, PartialOrd, Ord)] +pub struct Pass { + number: u32, +} + +impl Pass { + pub fn new(number: u32) -> Pass { + Pass { number } + } + + /// Its number, using it up. + pub fn redeem(self) -> u32 { + self.number + } +} + +/// A rank: a data enum with `Ord` whose fields are named as the comparison methods a +/// binding gives it, which each binding's names for them must keep apart. +#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)] +pub enum Rank { + Unranked, + Ranked { + compare: u8, + partial_compare: u8, + compare_to: u8, + partial_compare_to: u8, + }, +} + /// A tier: an enum whose derived `Ord` orders its variants as declared. #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)] pub enum Tier { diff --git a/ffi/src/dart.rs b/ffi/src/dart.rs index 41b85faa8..034a94b7c 100644 --- a/ffi/src/dart.rs +++ b/ffi/src/dart.rs @@ -2991,9 +2991,20 @@ fn member(snake: &str, reserved: &[&str]) -> String { } } -/// A field's Dart name. +/// A field's Dart name, clear of the members every object has and of the comparison methods +/// any type may gain, so a type that gains `PartialOrd` or `Ord` renames no field. fn field_name(name: &str) -> String { - member(name, OBJECT) + member( + name, + &[ + "hashCode", + "noSuchMethod", + "runtimeType", + "toString", + "compareTo", + "partialCompareTo", + ], + ) } /// A parameter's Dart name. The call's own locals end in `_`, which no camel-case name does. diff --git a/ffi/src/go.rs b/ffi/src/go.rs index fca976f97..cb644d9f5 100644 --- a/ffi/src/go.rs +++ b/ffi/src/go.rs @@ -43,7 +43,9 @@ use std::fmt::Write; use crate::abi::{self, Abi, Ty, pascal}; use crate::doc; -use crate::ir::{Access, Closure, Collection, Function, Home, Int, Literal, On, Order, Param, Receiver, Type}; +use crate::ir::{ + Access, Closure, Collection, Function, Home, Int, Literal, On, Order, Param, Receiver, Traits, Type, Variant, +}; const RUNTIME: &str = include_str!("../runtime/rt.go"); const CONVERSIONS: &str = include_str!("../runtime/ffi_cgo.go"); @@ -1684,7 +1686,7 @@ impl<'a> Gen<'a> { /// The methods a type's std traits export: `Display` is `String`, `Debug` `GoString`, /// `PartialEq` `Equal`, and `Clone` an object's `Clone`; and the package's function for /// `Default`. - fn traits(&mut self, ty: &Type, c: &str, t: crate::ir::Traits) -> (Vec, Option) { + fn traits(&mut self, ty: &Type, c: &str, t: Traits) -> (Vec, Option) { let name = self.go(ty); let object = matches!(ty, Type::Object(_)); let arena = self.arena(ty); @@ -2032,31 +2034,40 @@ impl<'a> Gen<'a> { /// field takes it. fn record_fields(&mut self, i: usize) -> Vec { let record = &self.abi.api.records[i]; - let t = record.traits; + let mut taken = self.trait_methods(&Type::Record(i), record.traits); + (record.fields.iter()) + .map(|f| { + let name = unique(&mut taken, field_name(&f.name)); + self.locked.insert( + format!("{} / field {}", crate::lock::type_key(&record.shown), f.name), + name.clone(), + ); + name + }) + .collect() + } + + /// The Go names of a data enum's variant's fields, clear of the methods its traits add. + fn variant_fields(&self, i: usize, variant: &Variant) -> Vec { + let mut taken = self.trait_methods(&Type::Enum(i), self.abi.api.enums[i].traits); + (variant.fields.iter()) + .map(|f| unique(&mut taken, field_name(&f.name))) + .collect() + } + + /// The methods the traits `t` of the type `ty` add, which a field's name must clear. + fn trait_methods(&self, ty: &Type, t: Traits) -> BTreeSet { let methods = [ (t.display, "String"), (t.debug, "GoString"), (t.eq, "Equal"), (t.ord != Order::None, "PartialCompare"), (t.ord == Order::Total, "Compare"), - (self.errored(&Type::Record(i)), "Error"), + (self.errored(ty), "Error"), ]; - let mut taken: BTreeSet = (methods.iter()) + (methods.iter()) .filter(|(has, _)| *has) .map(|(_, name)| name.to_string()) - .collect(); - (record.fields.iter()) - .map(|f| { - let mut name = field_name(&f.name); - while !taken.insert(name.clone()) { - name.push('_'); - } - self.locked.insert( - format!("{} / field {}", crate::lock::type_key(&record.shown), f.name), - name.clone(), - ); - name - }) .collect() } @@ -2259,8 +2270,8 @@ impl<'a> Gen<'a> { ); for variant in &e.variants { let vname = self.variants[&(c.clone(), variant.name.clone())].clone(); - let fields: Vec<(String, String)> = (variant.fields.iter()) - .map(|f| (field_name(&f.name), self.go(&f.ty))) + let fields: Vec<(String, String)> = (self.variant_fields(i, variant).into_iter()) + .zip(variant.fields.iter().map(|f| self.go(&f.ty))) .collect(); let mut members: Vec = fields.iter().map(|(f, _)| f.clone()).collect(); members.extend(methods.iter().map(|m| m.name.clone())); @@ -2330,15 +2341,16 @@ impl<'a> Gen<'a> { lowers.push(format!("\tcase {vname}:\n{check}\t\tc.tag = {n}\n")); continue; } - let lifted: Vec = (variant.fields.iter()) - .map(|f| { + let names = self.variant_fields(i, variant); + let lifted: Vec = (variant.fields.iter().zip(&names)) + .map(|(f, name)| { let value = self.lift(&f.ty, &format!("p.{}", cgo_field(&abi::escape(&f.name)))); - format!("{}: {value}", field_name(&f.name)) + format!("{name}: {value}") }) .collect(); - let lowered: Vec = (variant.fields.iter()) - .map(|f| { - let value = self.lower(&f.ty, &format!("v.{}", field_name(&f.name))); + let lowered: Vec = (variant.fields.iter().zip(&names)) + .map(|(f, name)| { + let value = self.lower(&f.ty, &format!("v.{name}")); format!("{}: {value}", cgo_field(&abi::escape(&f.name))) }) .collect(); @@ -3484,6 +3496,14 @@ fn c_int(int: Int) -> &'static str { } /// A field's Go name: in Pascal case, and `V0`, `V1`, ... for a positional one. +/// `name`, with `_` appended until it is clear of `taken`, which then holds it. +fn unique(taken: &mut BTreeSet, mut name: String) -> String { + while !taken.insert(name.clone()) { + name.push('_'); + } + name +} + fn field_name(name: &str) -> String { match name.starts_with(|c: char| c.is_ascii_digit()) { true => format!("V{name}"), diff --git a/ffi/src/kotlin.rs b/ffi/src/kotlin.rs index 2d0b5390e..07c917002 100644 --- a/ffi/src/kotlin.rs +++ b/ffi/src/kotlin.rs @@ -3831,8 +3831,6 @@ fn opaque_of(abi: &Abi<'_>, c: &Ty) -> Option { .and_then(|i| abi.api.records[i].opaque) } -/// The properties of an opaque value's class holding it, a word each: a value class's -/// `bits`, or `w0` and on. /// The `Comparable` a class ordered by `ord` implements, after `sep`: only a total order is. fn comparable(ord: Order, name: &str, sep: &str) -> String { match ord { @@ -3841,6 +3839,8 @@ fn comparable(ord: Order, name: &str, sep: &str) -> String { } } +/// The properties of an opaque value's class holding it, a word each: a value class's +/// `bits`, or `w0` and on. fn holders(opaque: &Opaque) -> Vec { match word(opaque) { true => vec!["bits".to_string()], diff --git a/ffi/surface/api/c.h b/ffi/surface/api/c.h index f9f324f56..344d507f4 100644 --- a/ffi/surface/api/c.h +++ b/ffi/surface/api/c.h @@ -7,7 +7,7 @@ #ifdef __cplusplus extern "C" { #endif -#define API_CONTRACT ((uint64_t)0x4ef55d1d8a723c39ULL) +#define API_CONTRACT ((uint64_t)0x0198e58b3ed63ec3ULL) uint64_t api_contract(void); uint32_t api_target(void); typedef int32_t api_status; @@ -146,6 +146,8 @@ typedef struct api_Stack api_Stack; typedef struct api_Refusal api_Refusal; typedef struct api_Fault api_Fault; typedef struct api_c api_c; +typedef struct api_Quantity api_Quantity; +typedef struct api_Pass api_Pass; typedef struct api_Key api_Key; typedef struct api_clash_Seed api_clash_Seed; typedef struct api_clash_Empty_string api_clash_Empty_string; @@ -180,6 +182,10 @@ typedef enum api_Family { typedef enum api_VecClashTone { API_VECCLASHTONE_ERROR = 0, } api_VecClashTone; +typedef enum api_Tier { + API_TIER_LOW = 0, + API_TIER_HIGH = 1, +} api_Tier; typedef enum api_Level { API_LEVEL_TRACE = 0, API_LEVEL_DEBUG = 1, @@ -815,6 +821,10 @@ typedef struct api_Qualifiers { double api; double kotlin; } api_Qualifiers; +typedef struct api_Version { + uint16_t major; + uint16_t minor; +} api_Version; typedef struct api_Spot { uint32_t x; uint32_t y; @@ -1068,6 +1078,22 @@ typedef struct api_Builtin { api_Builtin_Native native; }; } api_Builtin; +typedef enum api_Rank_tag { + API_RANK_UNRANKED = 0, + API_RANK_RANKED = 1, +} api_Rank_tag; +typedef struct api_Rank_Ranked { + uint8_t compare; + uint8_t partial_compare; + uint8_t compare_to; + uint8_t partial_compare_to; +} api_Rank_Ranked; +typedef struct api_Rank { + api_Rank_tag tag; + union { + api_Rank_Ranked ranked; + }; +} api_Rank; typedef enum api_clash_Candidate_tag { API_CLASH_CANDIDATE_NONE = 0, API_CLASH_CANDIDATE_MATCH = 1, @@ -1329,6 +1355,11 @@ bool api_a_eq(const api_a *a, const api_a *b); api_buf api_a_debug(const api_a *self); void api_Qualifiers_free(api_Qualifiers *self); bool api_Qualifiers_eq(const api_Qualifiers *a, const api_Qualifiers *b); +void api_Version_free(api_Version *self); +bool api_Version_eq(const api_Version *a, const api_Version *b); +int8_t api_Version_partial_cmp(const api_Version *a, const api_Version *b); +int8_t api_Version_cmp(const api_Version *a, const api_Version *b); +api_buf api_Version_debug(const api_Version *self); void api_Spot_free(api_Spot *self); bool api_Spot_eq(const api_Spot *a, const api_Spot *b); api_buf api_Spot_debug(const api_Spot *self); @@ -1435,11 +1466,22 @@ bool api_b_eq(const api_b *a, const api_b *b); api_buf api_b_debug(const api_b *self); void api_Builtin_free(api_Builtin *self); bool api_Builtin_eq(const api_Builtin *a, const api_Builtin *b); +void api_Rank_free(api_Rank *self); +bool api_Rank_eq(const api_Rank *a, const api_Rank *b); +int8_t api_Rank_partial_cmp(const api_Rank *a, const api_Rank *b); +int8_t api_Rank_cmp(const api_Rank *a, const api_Rank *b); +api_buf api_Rank_debug(const api_Rank *self); +bool api_Tier_eq(const api_Tier *a, const api_Tier *b); +int8_t api_Tier_partial_cmp(const api_Tier *a, const api_Tier *b); +int8_t api_Tier_cmp(const api_Tier *a, const api_Tier *b); +api_buf api_Tier_debug(const api_Tier *self); void api_clash_Candidate_free(api_clash_Candidate *self); bool api_clash_Candidate_eq(const api_clash_Candidate *a, const api_clash_Candidate *b); api_buf api_clash_Candidate_debug(const api_clash_Candidate *self); bool api_Level_eq(const api_Level *a, const api_Level *b); uint64_t api_Level_hash(const api_Level *self); +int8_t api_Level_partial_cmp(const api_Level *a, const api_Level *b); +int8_t api_Level_cmp(const api_Level *a, const api_Level *b); api_buf api_Level_to_string(const api_Level *self); void api_Board_free(api_Board *self); void api_Board_drop(api_Board *self, api_status *status); @@ -1929,6 +1971,19 @@ void api_c_free(api_c *self); bool api_c_eq(const api_c *a, const api_c *b); api_buf api_c_debug(const api_c *self); api_c *api_c_new(uint8_t value); +void api_Quantity_free(api_Quantity *self); +bool api_Quantity_eq(const api_Quantity *a, const api_Quantity *b); +int8_t api_Quantity_partial_cmp(const api_Quantity *a, const api_Quantity *b); +api_buf api_Quantity_debug(const api_Quantity *self); +api_Quantity *api_Quantity_new(int64_t value, uint32_t unit); +void api_Pass_free(api_Pass *self); +void api_Pass_drop(api_Pass *self, api_status *status); +bool api_Pass_eq(const api_Pass *a, const api_Pass *b, api_status *status); +int8_t api_Pass_partial_cmp(const api_Pass *a, const api_Pass *b, api_status *status); +int8_t api_Pass_cmp(const api_Pass *a, const api_Pass *b, api_status *status); +api_buf api_Pass_debug(const api_Pass *self, api_status *status); +api_Pass *api_Pass_new(uint32_t number); +uint32_t api_Pass_redeem(api_Pass *self, api_status *status); void api_Key_free(api_Key *self); bool api_Key_borrowed(const api_Key *self); api_Key *api_Key_clone(const api_Key *self); @@ -1957,6 +2012,8 @@ bool api_Url_borrowed(const api_Url *self); api_Url *api_Url_clone(const api_Url *self, api_status *status); bool api_Url_eq(const api_Url *a, const api_Url *b, api_status *status); uint64_t api_Url_hash(const api_Url *self, api_status *status); +int8_t api_Url_partial_cmp(const api_Url *a, const api_Url *b, api_status *status); +int8_t api_Url_cmp(const api_Url *a, const api_Url *b, api_status *status); api_buf api_Url_to_string(const api_Url *self, api_status *status); api_buf api_Url_debug(const api_Url *self, api_status *status); bool api_Url_parse(api_buf input, api_Url **out, api_buf *err); @@ -1969,6 +2026,8 @@ bool api_Instant_borrowed(const api_Instant *self); api_Instant *api_Instant_clone(const api_Instant *self); bool api_Instant_eq(const api_Instant *a, const api_Instant *b); uint64_t api_Instant_hash(const api_Instant *self); +int8_t api_Instant_partial_cmp(const api_Instant *a, const api_Instant *b); +int8_t api_Instant_cmp(const api_Instant *a, const api_Instant *b); api_buf api_Instant_debug(const api_Instant *self); void api_std_io_Error_free(api_std_io_Error *self); void api_std_io_Error_drop(api_std_io_Error *self, api_status *status); diff --git a/ffi/surface/api/cpp.hpp b/ffi/surface/api/cpp.hpp index 9d7c0140b..fc9d7fbdc 100644 --- a/ffi/surface/api/cpp.hpp +++ b/ffi/surface/api/cpp.hpp @@ -32,6 +32,10 @@ namespace api { enum class VecClashTone { error = 0, }; + enum class Tier { + low = 0, + high = 1, + }; inline constexpr ::std::uint64_t LIMIT = API_LIMIT; inline constexpr ::std::int64_t FAR = API_FAR; inline constexpr ::std::uint64_t URL = API_URL; @@ -574,6 +578,37 @@ namespace api { RUST2_FFI_CALLABLE ::api::buf debug() const; static ::api::c new_(::std::uint8_t value); }; + class RUST2_FFI_CONSUMABLE Quantity { + RUST2_FFI_UNCONSUMED Quantity(Quantity &&other RUST2_FFI_MOVED_FROM) noexcept = default; + Quantity &operator=(Quantity &&other) noexcept = default; + friend bool operator==(const Quantity &a__, const Quantity &b_); + friend bool operator!=(const Quantity &a__, const Quantity &b_); + friend bool operator<(const Quantity &a__, const Quantity &b_); + friend bool operator<=(const Quantity &a__, const Quantity &b_); + friend bool operator>(const Quantity &a__, const Quantity &b_); + friend bool operator>=(const Quantity &a__, const Quantity &b_); + #if defined(__cpp_lib_three_way_comparison) + friend ::std::partial_ordering operator<=>(const Quantity &a__, const Quantity &b_); + #endif + RUST2_FFI_CALLABLE ::api::buf debug() const; + static ::api::Quantity new_(::std::int64_t value, char32_t unit); + }; + class RUST2_FFI_CONSUMABLE Pass { + RUST2_FFI_UNCONSUMED Pass(Pass &&other RUST2_FFI_MOVED_FROM) noexcept = default; + Pass &operator=(Pass &&other) noexcept = default; + friend bool operator==(const Pass &a__, const Pass &b_); + friend bool operator!=(const Pass &a__, const Pass &b_); + friend bool operator<(const Pass &a__, const Pass &b_); + friend bool operator<=(const Pass &a__, const Pass &b_); + friend bool operator>(const Pass &a__, const Pass &b_); + friend bool operator>=(const Pass &a__, const Pass &b_); + #if defined(__cpp_lib_three_way_comparison) + friend ::std::weak_ordering operator<=>(const Pass &a__, const Pass &b_); + #endif + RUST2_FFI_CALLABLE ::api::buf debug() const; + static ::api::Pass new_(::std::uint32_t number); + RUST2_FFI_CONSUMES ::std::uint32_t redeem() &&; + }; class RUST2_FFI_CONSUMABLE Key { RUST2_FFI_UNCONSUMED Key(Key &&other RUST2_FFI_MOVED_FROM) noexcept = default; Key &operator=(Key &&other) noexcept = default; @@ -1092,6 +1127,20 @@ namespace api { friend bool operator==(const Qualifiers &a__, const Qualifiers &b_); friend bool operator!=(const Qualifiers &a__, const Qualifiers &b_); }; + struct Version { + ::std::uint16_t major; + ::std::uint16_t minor; + friend bool operator==(const Version &a__, const Version &b_); + friend bool operator!=(const Version &a__, const Version &b_); + friend bool operator<(const Version &a__, const Version &b_); + friend bool operator<=(const Version &a__, const Version &b_); + friend bool operator>(const Version &a__, const Version &b_); + friend bool operator>=(const Version &a__, const Version &b_); + #if defined(__cpp_lib_three_way_comparison) + friend ::std::weak_ordering operator<=>(const Version &a__, const Version &b_); + #endif + ::api::buf debug() const; + }; struct Spot { ::std::uint32_t x; ::std::uint32_t y; @@ -1285,6 +1334,14 @@ namespace api { struct Builtin_Native { double _0; }; + struct Rank_Unranked { + }; + struct Rank_Ranked { + ::std::uint8_t compare; + ::std::uint8_t partial_compare; + ::std::uint8_t compare_to; + ::std::uint8_t partial_compare_to; + }; struct clash_Candidate_None { }; struct clash_Candidate_Match { @@ -1338,6 +1395,14 @@ namespace api { inline bool operator==(const DoubleArray &a__, const DoubleArray &b_); inline bool operator==(const a &a__, const a &b_); inline bool operator==(const Qualifiers &a__, const Qualifiers &b_); + inline bool operator==(const Version &a__, const Version &b_); + inline bool operator<(const Version &a__, const Version &b_); + inline bool operator<=(const Version &a__, const Version &b_); + inline bool operator>(const Version &a__, const Version &b_); + inline bool operator>=(const Version &a__, const Version &b_); + #if defined(__cpp_lib_three_way_comparison) + inline ::std::weak_ordering operator<=>(const Version &a__, const Version &b_); + #endif inline bool operator==(const Spot &a__, const Spot &b_); inline bool operator==(const Deprecated &a__, const Deprecated &b_); inline bool operator==(const Dial &a__, const Dial &b_); @@ -1397,6 +1462,26 @@ namespace api { inline ::api::buf b_debug(const ::api::b &self); inline bool operator==(const ::api::Builtin &a__, const ::api::Builtin &b_); inline bool operator!=(const ::api::Builtin &a__, const ::api::Builtin &b_); + inline bool operator==(const ::api::Rank &a__, const ::api::Rank &b_); + inline bool operator!=(const ::api::Rank &a__, const ::api::Rank &b_); + inline bool operator<(const ::api::Rank &a__, const ::api::Rank &b_); + inline bool operator<=(const ::api::Rank &a__, const ::api::Rank &b_); + inline bool operator>(const ::api::Rank &a__, const ::api::Rank &b_); + inline bool operator>=(const ::api::Rank &a__, const ::api::Rank &b_); + #if defined(__cpp_lib_three_way_comparison) + inline ::std::weak_ordering operator<=>(const ::api::Rank &a__, const ::api::Rank &b_); + #endif + inline ::api::buf Rank_debug(const ::api::Rank &self); + inline bool operator==(::api::Tier a__, ::api::Tier b_); + inline bool operator!=(::api::Tier a__, ::api::Tier b_); + inline bool operator<(::api::Tier a__, ::api::Tier b_); + inline bool operator<=(::api::Tier a__, ::api::Tier b_); + inline bool operator>(::api::Tier a__, ::api::Tier b_); + inline bool operator>=(::api::Tier a__, ::api::Tier b_); + #if defined(__cpp_lib_three_way_comparison) + inline ::std::weak_ordering operator<=>(::api::Tier a__, ::api::Tier b_); + #endif + inline ::api::buf Tier_debug(::api::Tier self); inline bool operator==(const ::api::clash_Candidate &a__, const ::api::clash_Candidate &b_); inline bool operator!=(const ::api::clash_Candidate &a__, const ::api::clash_Candidate &b_); inline ::api::buf clash_Candidate_debug(const ::api::clash_Candidate &self); @@ -1813,6 +1898,9 @@ namespace api { #if defined(__cpp_impl_coroutine) && __cpp_impl_coroutine >= 201902L && __has_include() #include #endif +#if defined(__cpp_impl_three_way_comparison) && __cpp_impl_three_way_comparison >= 201907L && __has_include() +#include +#endif namespace api { #if defined(__clang__) #define RUST2_FFI_LIFETIMEBOUND [[clang::lifetimebound]] @@ -1964,6 +2052,7 @@ namespace api { enum class Status_; enum class Family; enum class VecClashTone; + enum class Tier; enum class Level; struct Parcel; struct Weighted; @@ -2022,6 +2111,7 @@ namespace api { struct NonZeros; struct a; struct Qualifiers; + struct Version; struct Spot; struct Deprecated; struct Dial; @@ -2092,6 +2182,8 @@ namespace api { class Refusal; class Fault; class c; + class Quantity; + class Pass; class Key; class clash_Seed; class clash_Empty_string; @@ -2165,6 +2257,9 @@ namespace api { struct Builtin_Int; struct Builtin_Native; using Builtin = ::std::variant; + struct Rank_Unranked; + struct Rank_Ranked; + using Rank = ::std::variant; struct clash_Candidate_None; struct clash_Candidate_Match; using clash_Candidate = ::std::variant; @@ -2262,6 +2357,13 @@ namespace api { Instant &operator=(const Instant &other) = default; friend bool operator==(const Instant &a__, const Instant &b_); friend bool operator!=(const Instant &a__, const Instant &b_); + friend bool operator<(const Instant &a__, const Instant &b_); + friend bool operator<=(const Instant &a__, const Instant &b_); + friend bool operator>(const Instant &a__, const Instant &b_); + friend bool operator>=(const Instant &a__, const Instant &b_); + #if defined(__cpp_lib_three_way_comparison) + friend ::std::weak_ordering operator<=>(const Instant &a__, const Instant &b_); + #endif RUST2_FFI_CALLABLE ::std::uint64_t hash() const; RUST2_FFI_CALLABLE ::api::buf debug() const; }; @@ -2352,6 +2454,13 @@ namespace api { }; inline bool operator==(::api::Level a__, ::api::Level b_); inline bool operator!=(::api::Level a__, ::api::Level b_); + inline bool operator<(::api::Level a__, ::api::Level b_); + inline bool operator<=(::api::Level a__, ::api::Level b_); + inline bool operator>(::api::Level a__, ::api::Level b_); + inline bool operator>=(::api::Level a__, ::api::Level b_); + #if defined(__cpp_lib_three_way_comparison) + inline ::std::weak_ordering operator<=>(::api::Level a__, ::api::Level b_); + #endif inline ::api::buf Level_to_string(::api::Level self); } #if defined(__GNUC__) || defined(__clang__) @@ -2380,6 +2489,13 @@ namespace api { Url &operator=(const Url &other) = default; friend bool operator==(const Url &a__, const Url &b_); friend bool operator!=(const Url &a__, const Url &b_); + friend bool operator<(const Url &a__, const Url &b_); + friend bool operator<=(const Url &a__, const Url &b_); + friend bool operator>(const Url &a__, const Url &b_); + friend bool operator>=(const Url &a__, const Url &b_); + #if defined(__cpp_lib_three_way_comparison) + friend ::std::weak_ordering operator<=>(const Url &a__, const Url &b_); + #endif RUST2_FFI_CALLABLE ::std::uint64_t hash() const; RUST2_FFI_CALLABLE ::api::buf to_string() const; RUST2_FFI_CALLABLE ::api::buf debug() const; diff --git a/ffi/surface/api/dart.dart b/ffi/surface/api/dart.dart index 2fa438543..2fed50ddf 100644 --- a/ffi/surface/api/dart.dart +++ b/ffi/surface/api/dart.dart @@ -615,6 +615,20 @@ final class Qualifiers { @override bool operator ==(Object other); @override int get hashCode; } +final class Version implements Comparable { + final int major; + final int minor; + const Version({required this.major, required this.minor}); + String debug(); + @override bool operator ==(Object other); + @override int get hashCode; + int? partialCompareTo(Version other); + bool operator <(Version other); + bool operator <=(Version other); + bool operator >(Version other); + bool operator >=(Version other); + @override int compareTo(Version other); +} final class Spot { final int x; final int y; @@ -962,6 +976,40 @@ final class BuiltinNative extends Builtin { final double $0; const BuiltinNative(this.$0); } +sealed class Rank implements Comparable { + const Rank(); + String debug(); + @override bool operator ==(Object other); + @override int get hashCode; + int? partialCompareTo(Rank other); + bool operator <(Rank other); + bool operator <=(Rank other); + bool operator >(Rank other); + bool operator >=(Rank other); + @override int compareTo(Rank other); +} +final class RankUnranked extends Rank { + const RankUnranked(); +} +final class RankRanked extends Rank { + final int compare; + final int partialCompare; + final int compareTo_; + final int partialCompareTo_; + const RankRanked({required this.compare, required this.partialCompare, required this.compareTo_, required this.partialCompareTo_}); +} +enum Tier implements Comparable { + low(0), + high(1), + const Tier(this._c); + String debug(); + int? partialCompareTo(Tier other); + bool operator <(Tier other); + bool operator <=(Tier other); + bool operator >(Tier other); + bool operator >=(Tier other); + @override int compareTo(Tier other); +} sealed class ClashCandidate { const ClashCandidate(); String debug(); @@ -975,7 +1023,7 @@ final class ClashCandidateMatch extends ClashCandidate { final int $0; const ClashCandidateMatch(this.$0); } -enum Level { +enum Level implements Comparable { trace(0), debug(1), info(2), @@ -983,6 +1031,12 @@ enum Level { error(4), const Level(this._c); @override String toString(); + int? partialCompareTo(Level other); + bool operator <(Level other); + bool operator <=(Level other); + bool operator >(Level other); + bool operator >=(Level other); + @override int compareTo(Level other); } final class Board extends _Object { factory Board(List<(String, Counter)> counters); @@ -1412,6 +1466,30 @@ final class C extends _Object { @override int get hashCode; factory C(int value); } +final class Quantity extends _Object { + String debug(); + @override bool operator ==(Object other); + @override int get hashCode; + int? partialCompareTo(Quantity other); + bool operator <(Quantity other); + bool operator <=(Quantity other); + bool operator >(Quantity other); + bool operator >=(Quantity other); + factory Quantity(int value, String unit); +} +final class Pass extends _Object implements Comparable { + String debug(); + @override bool operator ==(Object other); + @override int get hashCode; + int? partialCompareTo(Pass other); + bool operator <(Pass other); + bool operator <=(Pass other); + bool operator >(Pass other); + bool operator >=(Pass other); + @override int compareTo(Pass other); + factory Pass(int number); + int redeem(); +} final class Key extends _Object { String debug(); Key clone(); @@ -1438,23 +1516,35 @@ final class TlsSession extends _Object { String alpn(); TlsPolicyLifetime lifetime(); } -final class Url extends _Object { +final class Url extends _Object implements Comparable { @override String toString(); String debug(); Url clone(); @override bool operator ==(Object other); @override int get hashCode; + int? partialCompareTo(Url other); + bool operator <(Url other); + bool operator <=(Url other); + bool operator >(Url other); + bool operator >=(Url other); + @override int compareTo(Url other); factory Url.parse(String input); } final class Json extends _Object { factory Json.parse(String input); String toText(); } -final class Instant extends _Object { +final class Instant extends _Object implements Comparable { String debug(); Instant clone(); @override bool operator ==(Object other); @override int get hashCode; + int? partialCompareTo(Instant other); + bool operator <(Instant other); + bool operator <=(Instant other); + bool operator >(Instant other); + bool operator >=(Instant other); + @override int compareTo(Instant other); } final class StdIoError extends _Object { } diff --git a/ffi/surface/api/go.txt b/ffi/surface/api/go.txt index f0d671c5a..e374ad326 100644 --- a/ffi/surface/api/go.txt +++ b/ffi/surface/api/go.txt @@ -1347,6 +1347,16 @@ func (self *Part) Equal(other *Part) (bool, error) func (self *Part) GoString() string func (self *Part) ValueGet() (uint64, error) func (self *Part) ValueSet(value uint64) error +type Pass struct { + Handle_ *p_rt.Handle_ +} +func NewPass(number uint32) *Pass +func (self *Pass) Close() error +func (self *Pass) Compare(other *Pass) (int, error) +func (self *Pass) Equal(other *Pass) (bool, error) +func (self *Pass) GoString() string +func (self *Pass) PartialCompare(other *Pass) (int, bool, error) +func (self *Pass) Redeem() (uint32, error) type Peer struct { Addr p_rt.SocketAddr Names []string @@ -1430,6 +1440,28 @@ func (self *Quantity) Close() error func (self *Quantity) Equal(other *Quantity) (bool, error) func (self *Quantity) GoString() string func (self *Quantity) PartialCompare(other *Quantity) (int, bool, error) +type Rank interface { + GoString() string + Equal(other Rank) bool + PartialCompare(other Rank) (int, bool) + Compare(other Rank) int +} +type RankRanked struct { + Compare_ uint8 + PartialCompare_ uint8 + CompareTo uint8 + PartialCompareTo uint8 +} +func (self RankRanked) Compare(other Rank) int +func (self RankRanked) Equal(other Rank) bool +func (self RankRanked) GoString() string +func (self RankRanked) PartialCompare(other Rank) (int, bool) +type RankUnranked struct { +} +func (self RankUnranked) Compare(other Rank) int +func (self RankUnranked) Equal(other Rank) bool +func (self RankUnranked) GoString() string +func (self RankUnranked) PartialCompare(other Rank) (int, bool) type Rated struct { Bytes_ [2]uint64 Made_ bool diff --git a/ffi/surface/api/kotlin.kt b/ffi/surface/api/kotlin.kt index 0e7b7336c..7159f9464 100644 --- a/ffi/surface/api/kotlin.kt +++ b/ffi/surface/api/kotlin.kt @@ -369,6 +369,11 @@ data class Qualifiers(val api: kotlin.Double, val kotlin: kotlin.Double) { override fun equals(other: kotlin.Any?): kotlin.Boolean override fun hashCode(): kotlin.Int } +data class Version(val major: kotlin.UShort, val minor: kotlin.UShort) : kotlin.Comparable { + fun debug(): kotlin.String + fun partialCompareTo(other: api.Version): kotlin.Int? + override fun compareTo(other: api.Version): kotlin.Int +} data class Spot(val x: kotlin.UInt, val y: kotlin.UInt) { fun debug(): kotlin.String companion object { @@ -555,6 +560,20 @@ sealed class Builtin { override fun hashCode(): kotlin.Int } } +sealed class Rank : kotlin.Comparable { + data object Unranked : Rank() + data class Ranked(val compare: kotlin.UByte, val partialCompare: kotlin.UByte, val compareTo: kotlin.UByte, val partialCompareTo: kotlin.UByte) : Rank() + fun debug(): kotlin.String + fun partialCompareTo(other: api.Rank): kotlin.Int? + override fun compareTo(other: api.Rank): kotlin.Int +} +enum class Tier(internal val value: Int) { + LOW(0), + HIGH(1); + fun debug(): kotlin.String + fun partialCompareTo(other: api.Tier): kotlin.Int? + companion object {} +} sealed class ClashCandidate { data object None : ClashCandidate() data class Match(val _0: kotlin.UByte) : ClashCandidate() @@ -567,6 +586,7 @@ enum class Level(internal val value: Int) { WARN(3), ERROR(4); final override fun toString(): kotlin.String + fun partialCompareTo(other: api.Level): kotlin.Int? companion object {} } class Board internal constructor(raw: Long, lent: Boolean = false) : AutoCloseable { @@ -1153,6 +1173,28 @@ class C internal constructor(raw: Long, lent: Boolean = false) : AutoCloseable { @kotlin.jvm.JvmStatic fun new(value: kotlin.UByte): api.C } } +class Quantity internal constructor(raw: Long, lent: Boolean = false) : AutoCloseable { + override fun close() + fun debug(): kotlin.String + override fun equals(other: kotlin.Any?): kotlin.Boolean + override fun hashCode(): kotlin.Int + fun partialCompareTo(other: api.Quantity): kotlin.Int? + companion object { + @kotlin.jvm.JvmStatic fun new(value: kotlin.Long, unit: kotlin.Int): api.Quantity + } +} +class Pass internal constructor(raw: Long, lent: Boolean = false) : AutoCloseable, kotlin.Comparable { + override fun close() + fun debug(): kotlin.String + override fun equals(other: kotlin.Any?): kotlin.Boolean + override fun hashCode(): kotlin.Int + fun partialCompareTo(other: api.Pass): kotlin.Int? + override fun compareTo(other: api.Pass): kotlin.Int + fun redeem(): kotlin.UInt + companion object { + @kotlin.jvm.JvmStatic fun new(number: kotlin.UInt): api.Pass + } +} class Key internal constructor(raw: Long, lent: Boolean = false) : AutoCloseable { override fun close() fun debug(): kotlin.String @@ -1190,13 +1232,15 @@ class TlsSession internal constructor(raw: Long, lent: Boolean = false) : AutoCl fun alpn(): kotlin.String fun lifetime(): api.TlsPolicyLifetime } -class Url internal constructor(raw: Long, lent: Boolean = false) : AutoCloseable { +class Url internal constructor(raw: Long, lent: Boolean = false) : AutoCloseable, kotlin.Comparable { override fun close() final override fun toString(): kotlin.String fun debug(): kotlin.String fun clone(): api.Url override fun equals(other: kotlin.Any?): kotlin.Boolean override fun hashCode(): kotlin.Int + fun partialCompareTo(other: api.Url): kotlin.Int? + override fun compareTo(other: api.Url): kotlin.Int companion object { @kotlin.jvm.JvmStatic @kotlin.jvm.Throws(StringException::class) fun parse(input: kotlin.String): api.Url } @@ -1208,12 +1252,14 @@ class Json internal constructor(raw: Long, lent: Boolean = false) : AutoCloseabl @kotlin.jvm.JvmStatic @kotlin.jvm.Throws(StringException::class) fun parse(input: kotlin.String): api.Json } } -class Instant internal constructor(raw: Long, lent: Boolean = false) : AutoCloseable { +class Instant internal constructor(raw: Long, lent: Boolean = false) : AutoCloseable, kotlin.Comparable { override fun close() fun debug(): kotlin.String fun clone(): api.Instant override fun equals(other: kotlin.Any?): kotlin.Boolean override fun hashCode(): kotlin.Int + fun partialCompareTo(other: api.Instant): kotlin.Int? + override fun compareTo(other: api.Instant): kotlin.Int } class StdIoError internal constructor(raw: Long, lent: Boolean = false) : AutoCloseable { override fun close() diff --git a/ffi/surface/api/python.pyi b/ffi/surface/api/python.pyi index baf9647c9..d03c78735 100644 --- a/ffi/surface/api/python.pyi +++ b/ffi/surface/api/python.pyi @@ -425,6 +425,16 @@ class Qualifiers(_Record): kotlin: _float def __init__(self, api: _float, kotlin: _float) -> None: ... def __eq__(self, other: _object) -> _bool: ... +class Version(_Record): + major: _int + minor: _int + def __init__(self, major: _int, minor: _int) -> None: ... + def __eq__(self, other: _object) -> _bool: ... + def __lt__(self, other: _object) -> _bool: ... + def __le__(self, other: _object) -> _bool: ... + def __gt__(self, other: _object) -> _bool: ... + def __ge__(self, other: _object) -> _bool: ... + def __repr__(self) -> _str: ... class Spot(_Record): x: _int y: _int @@ -743,6 +753,31 @@ class _Builtin_Native(Builtin, _Record): _0: _float def __init__(self, _0: _float) -> None: ... def __eq__(self, other: _object) -> _bool: ... +class Rank: + def __lt__(self, other: _object) -> _bool: ... + def __le__(self, other: _object) -> _bool: ... + def __gt__(self, other: _object) -> _bool: ... + def __ge__(self, other: _object) -> _bool: ... + def __repr__(self) -> _str: ... + Unranked: _typing.TypeAlias = '_Rank_Unranked' + Ranked: _typing.TypeAlias = '_Rank_Ranked' +class _Rank_Unranked(Rank, _Record): + def __eq__(self, other: _object) -> _bool: ... +class _Rank_Ranked(Rank, _Record): + compare: _int + partial_compare: _int + compare_to: _int + partial_compare_to: _int + def __init__(self, compare: _int, partial_compare: _int, compare_to: _int, partial_compare_to: _int) -> None: ... + def __eq__(self, other: _object) -> _bool: ... +class Tier(_enum.Enum): + LOW = 0 + HIGH = 1 + def __lt__(self, other: _object) -> _bool: ... + def __le__(self, other: _object) -> _bool: ... + def __gt__(self, other: _object) -> _bool: ... + def __ge__(self, other: _object) -> _bool: ... + def __repr__(self) -> _str: ... class ClashCandidate: def __repr__(self) -> _str: ... None_: _typing.TypeAlias = '_ClashCandidate_None_' @@ -759,6 +794,10 @@ class Level(_enum.Enum): INFO = 2 WARN = 3 ERROR = 4 + def __lt__(self, other: _object) -> _bool: ... + def __le__(self, other: _object) -> _bool: ... + def __gt__(self, other: _object) -> _bool: ... + def __ge__(self, other: _object) -> _bool: ... def __str__(self) -> _str: ... class Board(_n.Object): @_staticmethod @@ -1226,6 +1265,25 @@ class C(_n.Object): def __repr__(self) -> _str: ... @_staticmethod def new(value: _int) -> C: ... +class Quantity(_n.Object): + def __eq__(self, other: _object) -> _bool: ... + def __lt__(self, other: _object) -> _bool: ... + def __le__(self, other: _object) -> _bool: ... + def __gt__(self, other: _object) -> _bool: ... + def __ge__(self, other: _object) -> _bool: ... + def __repr__(self) -> _str: ... + @_staticmethod + def new(value: _int, unit: _str) -> Quantity: ... +class Pass(_n.Object): + def __eq__(self, other: _object) -> _bool: ... + def __lt__(self, other: _object) -> _bool: ... + def __le__(self, other: _object) -> _bool: ... + def __gt__(self, other: _object) -> _bool: ... + def __ge__(self, other: _object) -> _bool: ... + def __repr__(self) -> _str: ... + @_staticmethod + def new(number: _int) -> Pass: ... + def redeem(self) -> _int: ... class Key(_n.Object): def __eq__(self, other: _object) -> _bool: ... def __repr__(self) -> _str: ... @@ -1253,6 +1311,10 @@ class TlsSession(_n.Object): def lifetime(self) -> TlsPolicyLifetime: ... class Url(_n.Object): def __eq__(self, other: _object) -> _bool: ... + def __lt__(self, other: _object) -> _bool: ... + def __le__(self, other: _object) -> _bool: ... + def __gt__(self, other: _object) -> _bool: ... + def __ge__(self, other: _object) -> _bool: ... def __str__(self) -> _str: ... def __repr__(self) -> _str: ... def clone(self) -> Url: ... @@ -1265,6 +1327,10 @@ class Json(_n.Object): def to_text(self) -> _str: ... class Instant(_n.Object): def __eq__(self, other: _object) -> _bool: ... + def __lt__(self, other: _object) -> _bool: ... + def __le__(self, other: _object) -> _bool: ... + def __gt__(self, other: _object) -> _bool: ... + def __ge__(self, other: _object) -> _bool: ... def __repr__(self) -> _str: ... def clone(self) -> Instant: ... def __hash__(self) -> _int: ... diff --git a/ffi/surface/api/swift.swift b/ffi/surface/api/swift.swift index add1dac10..fa122a216 100644 --- a/ffi/surface/api/swift.swift +++ b/ffi/surface/api/swift.swift @@ -580,6 +580,17 @@ public struct Qualifiers: Sendable, Equatable { @inlinable public init(api: Swift.Double, kotlin: Swift.Double) @inlinable public static func == (a: Qualifiers, b: Qualifiers) -> Swift.Bool } +public struct Version: Sendable, CustomDebugStringConvertible, Equatable, Comparable { + public var major: Swift.UInt16 + public var minor: Swift.UInt16 + @inlinable public init(major: Swift.UInt16, minor: Swift.UInt16) + @inlinable public var debugDescription: Swift.String { get } + @inlinable public static func == (a: Version, b: Version) -> Swift.Bool + @inlinable public static func < (a: Version, b: Version) -> Swift.Bool + @inlinable public static func <= (a: Version, b: Version) -> Swift.Bool + @inlinable public static func > (a: Version, b: Version) -> Swift.Bool + @inlinable public static func >= (a: Version, b: Version) -> Swift.Bool +} public struct Spot: Sendable, CustomDebugStringConvertible, Equatable { public var x: Swift.UInt32 public var y: Swift.UInt32 @@ -787,13 +798,33 @@ public enum Builtin: Sendable, Equatable { case native(Swift.Double) @inlinable public static func == (a: Builtin, b: Builtin) -> Swift.Bool } +public enum Rank: Sendable, CustomDebugStringConvertible, Equatable, Comparable { + case unranked + case ranked(compare: Swift.UInt8, partialCompare: Swift.UInt8, compareTo: Swift.UInt8, partialCompareTo: Swift.UInt8) + @inlinable public var debugDescription: Swift.String { get } + @inlinable public static func == (a: Rank, b: Rank) -> Swift.Bool + @inlinable public static func < (a: Rank, b: Rank) -> Swift.Bool + @inlinable public static func <= (a: Rank, b: Rank) -> Swift.Bool + @inlinable public static func > (a: Rank, b: Rank) -> Swift.Bool + @inlinable public static func >= (a: Rank, b: Rank) -> Swift.Bool +} +public enum Tier: Sendable, CustomDebugStringConvertible, Equatable, Comparable { + case low + case high + @inlinable public var debugDescription: Swift.String { get } + @inlinable public static func == (a: Tier, b: Tier) -> Swift.Bool + @inlinable public static func < (a: Tier, b: Tier) -> Swift.Bool + @inlinable public static func <= (a: Tier, b: Tier) -> Swift.Bool + @inlinable public static func > (a: Tier, b: Tier) -> Swift.Bool + @inlinable public static func >= (a: Tier, b: Tier) -> Swift.Bool +} public enum ClashCandidate: Sendable, CustomDebugStringConvertible, Equatable { case none case match(Swift.UInt8) @inlinable public var debugDescription: Swift.String { get } @inlinable public static func == (a: ClashCandidate, b: ClashCandidate) -> Swift.Bool } -public enum Level: Sendable, CustomStringConvertible, Hashable { +public enum Level: Sendable, CustomStringConvertible, Hashable, Comparable { case trace case debug case info @@ -801,6 +832,10 @@ public enum Level: Sendable, CustomStringConvertible, Hashable { case error @inlinable public var description: Swift.String { get } @inlinable public static func == (a: Level, b: Level) -> Swift.Bool + @inlinable public static func < (a: Level, b: Level) -> Swift.Bool + @inlinable public static func <= (a: Level, b: Level) -> Swift.Bool + @inlinable public static func > (a: Level, b: Level) -> Swift.Bool + @inlinable public static func >= (a: Level, b: Level) -> Swift.Bool @inlinable public func hash(into hasher: inout Swift.Hasher) } public struct Board: ~Copyable, @unchecked Sendable { @@ -1237,6 +1272,28 @@ public struct C: ~Copyable, @unchecked Sendable { #if compiler(>=6.4) extension C: Equatable {} #endif +public struct Quantity: ~Copyable, @unchecked Sendable { + @inlinable public var debugDescription: Swift.String { get } + @inlinable public static func == (a: borrowing Quantity, b: borrowing Quantity) -> Swift.Bool + @inlinable public static func < (a: borrowing Quantity, b: borrowing Quantity) -> Swift.Bool + @inlinable public static func <= (a: borrowing Quantity, b: borrowing Quantity) -> Swift.Bool + @inlinable public static func > (a: borrowing Quantity, b: borrowing Quantity) -> Swift.Bool + @inlinable public static func >= (a: borrowing Quantity, b: borrowing Quantity) -> Swift.Bool + @inlinable public static func new(_ value: Swift.Int64, _ unit: Swift.Unicode.Scalar) -> Quantity +} +#if compiler(>=6.4) +extension Quantity: Equatable {} +#endif +public struct Pass: ~Copyable, @unchecked Sendable { + @inlinable public var debugDescription: Swift.String { get } + @inlinable public static func == (a: borrowing Pass, b: borrowing Pass) throws -> Swift.Bool + @inlinable public static func < (a: borrowing Pass, b: borrowing Pass) throws -> Swift.Bool + @inlinable public static func <= (a: borrowing Pass, b: borrowing Pass) throws -> Swift.Bool + @inlinable public static func > (a: borrowing Pass, b: borrowing Pass) throws -> Swift.Bool + @inlinable public static func >= (a: borrowing Pass, b: borrowing Pass) throws -> Swift.Bool + @inlinable public static func new(_ number: Swift.UInt32) -> Pass + @inlinable public consuming func redeem() throws -> Swift.UInt32 +} public struct Key: ~Copyable, @unchecked Sendable { @inlinable public var debugDescription: Swift.String { get } @inlinable public func clone() -> Key @@ -1271,6 +1328,10 @@ public struct Url: ~Copyable, @unchecked Sendable { @inlinable public var debugDescription: Swift.String { get } @inlinable public func clone() throws -> Url @inlinable public static func == (a: borrowing Url, b: borrowing Url) throws -> Swift.Bool + @inlinable public static func < (a: borrowing Url, b: borrowing Url) throws -> Swift.Bool + @inlinable public static func <= (a: borrowing Url, b: borrowing Url) throws -> Swift.Bool + @inlinable public static func > (a: borrowing Url, b: borrowing Url) throws -> Swift.Bool + @inlinable public static func >= (a: borrowing Url, b: borrowing Url) throws -> Swift.Bool @inlinable public func hash(into hasher: inout Swift.Hasher) throws @inlinable public static func parse(_ input: Swift.String) throws -> Url } @@ -1278,10 +1339,14 @@ public struct Json: ~Copyable, @unchecked Sendable { @inlinable public static func parse(_ input: Swift.String) throws -> Json @inlinable public func toText() throws -> Swift.String } -public final class Instant: @unchecked Sendable, CustomDebugStringConvertible, Hashable { +public final class Instant: @unchecked Sendable, CustomDebugStringConvertible, Hashable, Comparable { @inlinable public var debugDescription: Swift.String { get } @inlinable public func clone() -> Instant @inlinable public static func == (a: Instant, b: Instant) -> Swift.Bool + @inlinable public static func < (a: Instant, b: Instant) -> Swift.Bool + @inlinable public static func <= (a: Instant, b: Instant) -> Swift.Bool + @inlinable public static func > (a: Instant, b: Instant) -> Swift.Bool + @inlinable public static func >= (a: Instant, b: Instant) -> Swift.Bool @inlinable public func hash(into hasher: inout Swift.Hasher) } public struct StdIoError: ~Copyable, @unchecked Sendable {} diff --git a/ffi/surface/api/web.d.ts b/ffi/surface/api/web.d.ts index 2a734c171..bdd49f1a6 100644 --- a/ffi/surface/api/web.d.ts +++ b/ffi/surface/api/web.d.ts @@ -1043,6 +1043,17 @@ export type Parcel = { payload: Uint8Array; }; +// Pass.ts +import * as rt from "./rt.ts"; +export type Pass = rt.Handle<"Pass">; +export declare function debug(self: Pass): string; +export declare function eq(a: Pass, b: Pass): boolean; +export declare function partialCmp(a: Pass, b: Pass): number | undefined; +export declare function cmp(a: Pass, b: Pass): number; +export declare function new$(number: number): Pass; +export declare function redeem(self: Pass): number; +export { new$ as new }; + // Peer.ts import * as rt from "./rt.ts"; export type Peer = { @@ -1131,6 +1142,21 @@ export declare function partialCmp(a: Quantity, b: Quantity): number | undefined export declare function new$(value: rt.i64, unit: number): Quantity; export { new$ as new }; +// Rank.ts +export type Rank = { + tag: "Unranked"; +} | { + tag: "Ranked"; + compare: number; + partialCompare: number; + compareTo: number; + partialCompareTo: number; +}; +export declare function debug(self: Rank): string; +export declare function eq(a: Rank, b: Rank): boolean; +export declare function partialCmp(a: Rank, b: Rank): number | undefined; +export declare function cmp(a: Rank, b: Rank): number; + // Rated.ts import * as rt from "./rt.ts"; export type Rated = rt.Opaque<"Rated">; @@ -1690,6 +1716,7 @@ import type { PolarPoint } from "./PolarPoint.ts"; import type { PolarTurn } from "./PolarTurn.ts"; import type { Polar_Turn } from "./Polar_Turn.ts"; import type { Qualifiers } from "./Qualifiers.ts"; +import type { Rank } from "./Rank.ts"; import type { Rated } from "./Rated.ts"; import type { Reading } from "./Reading.ts"; import type { Refusal } from "./Refusal.ts"; @@ -1785,6 +1812,7 @@ export declare const k_Node: rt.Kind; export declare const k_Outer_Inner_u8: rt.Kind; export declare const k_Pad_u16: rt.Kind; export declare const k_Pad_u8: rt.Kind; +export declare const k_Pass: rt.Kind; export declare const k_Plain: rt.Kind; export declare const k_Quantity: rt.Kind; export declare const k_Receipt: rt.Kind; @@ -2078,6 +2106,7 @@ export declare function w_Platform(p: number, v: Platform): void; export declare function w_Point(p: number, v: Point): void; export declare function w_PolarTurn(p: number, v: PolarTurn): void; export declare function w_Qualifiers(p: number, v: Qualifiers): void; +export declare function w_Rank(p: number, v: Rank): void; export declare function w_Rated(p: number, v: Rated): void; export declare function w_Reading(p: number, v: Reading): void; export declare function w_Right_Left_u8(p: number, v: RightLeftU8): void; diff --git a/ffi/surface/moq/c.h b/ffi/surface/moq/c.h index 637508de6..fafc47e25 100644 --- a/ffi/surface/moq/c.h +++ b/ffi/surface/moq/c.h @@ -7,7 +7,7 @@ #ifdef __cplusplus extern "C" { #endif -#define MOQ_CONTRACT ((uint64_t)0x0ac854b23d858bf7ULL) +#define MOQ_CONTRACT ((uint64_t)0x171f68ee1c58986eULL) uint64_t moq_contract(void); uint32_t moq_target(void); typedef int32_t moq_status; @@ -2340,6 +2340,8 @@ moq_buf moq_TimeOverflow_to_string(const moq_TimeOverflow *self); moq_buf moq_TimeOverflow_debug(const moq_TimeOverflow *self); bool moq_Timescale_eq(const moq_Timescale *a, const moq_Timescale *b); uint64_t moq_Timescale_hash(const moq_Timescale *self); +int8_t moq_Timescale_partial_cmp(const moq_Timescale *a, const moq_Timescale *b); +int8_t moq_Timescale_cmp(const moq_Timescale *a, const moq_Timescale *b); moq_buf moq_Timescale_to_string(const moq_Timescale *self); moq_buf moq_Timescale_debug(const moq_Timescale *self); moq_Timescale moq_Timescale_SECOND(void); @@ -2350,6 +2352,7 @@ bool moq_Timescale_new(uint64_t units_per_second, moq_Timescale *out, moq_TimeOv uint64_t moq_Timescale_as_u64(const moq_Timescale *self); bool moq_Timestamp_eq(const moq_Timestamp *a, const moq_Timestamp *b); uint64_t moq_Timestamp_hash(const moq_Timestamp *self); +int8_t moq_Timestamp_partial_cmp(const moq_Timestamp *a, const moq_Timestamp *b); moq_buf moq_Timestamp_debug(const moq_Timestamp *self); moq_Timestamp moq_Timestamp_ZERO(void); bool moq_Timestamp_new(uint64_t value, moq_Timescale scale, moq_Timestamp *out, moq_TimeOverflow *err); @@ -2372,6 +2375,8 @@ bool moq_Timestamp_checked_add(const moq_Timestamp *self, moq_Timestamp rhs, moq bool moq_Timestamp_checked_sub(const moq_Timestamp *self, moq_Timestamp rhs, moq_Timestamp *out, moq_TimeOverflow *err); bool moq_clock_Instant_eq(const moq_clock_Instant *a, const moq_clock_Instant *b); uint64_t moq_clock_Instant_hash(const moq_clock_Instant *self); +int8_t moq_clock_Instant_partial_cmp(const moq_clock_Instant *a, const moq_clock_Instant *b); +int8_t moq_clock_Instant_cmp(const moq_clock_Instant *a, const moq_clock_Instant *b); moq_buf moq_clock_Instant_debug(const moq_clock_Instant *self); moq_clock_Instant moq_clock_Instant_ZERO(void); moq_clock_Instant moq_clock_Instant_now(void); @@ -2390,6 +2395,8 @@ moq_buf moq_clock_Elapsed_to_string(const moq_clock_Elapsed *self); moq_buf moq_clock_Elapsed_debug(const moq_clock_Elapsed *self); bool moq_clock_Wall_eq(const moq_clock_Wall *a, const moq_clock_Wall *b); uint64_t moq_clock_Wall_hash(const moq_clock_Wall *self); +int8_t moq_clock_Wall_partial_cmp(const moq_clock_Wall *a, const moq_clock_Wall *b); +int8_t moq_clock_Wall_cmp(const moq_clock_Wall *a, const moq_clock_Wall *b); moq_buf moq_clock_Wall_debug(const moq_clock_Wall *self); moq_clock_Wall moq_clock_Wall_UNIX_EPOCH(void); moq_clock_Wall moq_clock_Wall_MOQ_EPOCH(void); @@ -2608,6 +2615,8 @@ moq_option_non_zero_u64 moq_transport_Limits_receive_window_get(const moq_transp void moq_transport_Limits_receive_window_set(moq_transport_Limits *self, moq_option_non_zero_u64 value); bool moq_bandwidth_Rate_eq(const moq_bandwidth_Rate *a, const moq_bandwidth_Rate *b); uint64_t moq_bandwidth_Rate_hash(const moq_bandwidth_Rate *self); +int8_t moq_bandwidth_Rate_partial_cmp(const moq_bandwidth_Rate *a, const moq_bandwidth_Rate *b); +int8_t moq_bandwidth_Rate_cmp(const moq_bandwidth_Rate *a, const moq_bandwidth_Rate *b); moq_buf moq_bandwidth_Rate_debug(const moq_bandwidth_Rate *self); moq_bandwidth_Rate moq_bandwidth_Rate_default(void); moq_bandwidth_Rate moq_bandwidth_Rate_ZERO(void); @@ -2625,6 +2634,8 @@ moq_buf moq_frame_Info_debug(const moq_frame_Info *self); void moq_group_Info_free(moq_group_Info *self); bool moq_group_Info_eq(const moq_group_Info *a, const moq_group_Info *b); uint64_t moq_group_Info_hash(const moq_group_Info *self); +int8_t moq_group_Info_partial_cmp(const moq_group_Info *a, const moq_group_Info *b); +int8_t moq_group_Info_cmp(const moq_group_Info *a, const moq_group_Info *b); moq_buf moq_group_Info_debug(const moq_group_Info *self); void moq_track_Delay_free(moq_track_Delay *self); bool moq_track_Delay_eq(const moq_track_Delay *a, const moq_track_Delay *b); @@ -2634,6 +2645,8 @@ moq_track_Delay moq_track_Delay_with_min(const moq_track_Delay *self, moq_option moq_track_Delay moq_track_Delay_with_max(const moq_track_Delay *self, moq_option_duration max); bool moq_track_Position_eq(const moq_track_Position *a, const moq_track_Position *b); uint64_t moq_track_Position_hash(const moq_track_Position *self); +int8_t moq_track_Position_partial_cmp(const moq_track_Position *a, const moq_track_Position *b); +int8_t moq_track_Position_cmp(const moq_track_Position *a, const moq_track_Position *b); moq_buf moq_track_Position_debug(const moq_track_Position *self); moq_track_Position moq_track_Position_default(void); uint64_t moq_track_Position_group_get(const moq_track_Position *self); @@ -2645,16 +2658,22 @@ moq_track_Position moq_track_Position_group(uint64_t group); void moq_track_Range_free(moq_track_Range *self); bool moq_track_Range_eq(const moq_track_Range *a, const moq_track_Range *b); uint64_t moq_track_Range_hash(const moq_track_Range *self); +int8_t moq_track_Range_partial_cmp(const moq_track_Range *a, const moq_track_Range *b); +int8_t moq_track_Range_cmp(const moq_track_Range *a, const moq_track_Range *b); moq_buf moq_track_Range_debug(const moq_track_Range *self); moq_track_Range moq_track_Range_live(void); moq_track_Range moq_track_Range_oldest(void); bool moq_origin_Cost_eq(const moq_origin_Cost *a, const moq_origin_Cost *b); +int8_t moq_origin_Cost_partial_cmp(const moq_origin_Cost *a, const moq_origin_Cost *b); +int8_t moq_origin_Cost_cmp(const moq_origin_Cost *a, const moq_origin_Cost *b); moq_buf moq_origin_Cost_debug(const moq_origin_Cost *self); moq_origin_Cost moq_origin_Cost_default(void); moq_origin_Cost moq_origin_Cost_new(uint64_t cost); uint64_t moq_origin_Cost_value(const moq_origin_Cost *self); bool moq_origin_Priority_eq(const moq_origin_Priority *a, const moq_origin_Priority *b); uint64_t moq_origin_Priority_hash(const moq_origin_Priority *self); +int8_t moq_origin_Priority_partial_cmp(const moq_origin_Priority *a, const moq_origin_Priority *b); +int8_t moq_origin_Priority_cmp(const moq_origin_Priority *a, const moq_origin_Priority *b); moq_buf moq_origin_Priority_debug(const moq_origin_Priority *self); moq_origin_Priority moq_origin_Priority_default(void); moq_origin_Priority moq_origin_Priority_new(int8_t priority); @@ -2870,6 +2889,8 @@ moq_track_Compression moq_track_Compression_default(void); void moq_track_Anchor_free(moq_track_Anchor *self); bool moq_track_Anchor_eq(const moq_track_Anchor *a, const moq_track_Anchor *b); uint64_t moq_track_Anchor_hash(const moq_track_Anchor *self); +int8_t moq_track_Anchor_partial_cmp(const moq_track_Anchor *a, const moq_track_Anchor *b); +int8_t moq_track_Anchor_cmp(const moq_track_Anchor *a, const moq_track_Anchor *b); moq_buf moq_track_Anchor_debug(const moq_track_Anchor *self); bool moq_track_Order_eq(const moq_track_Order *a, const moq_track_Order *b); uint64_t moq_track_Order_hash(const moq_track_Order *self); @@ -3049,6 +3070,8 @@ moq_buf moq_moq_sock_udp_EcnCodepoint_debug(const moq_moq_sock_udp_EcnCodepoint moq_option_moq_sock_udp_EcnCodepoint moq_moq_sock_udp_EcnCodepoint_from_bits(uint8_t x); bool moq_Level_eq(const moq_Level *a, const moq_Level *b); uint64_t moq_Level_hash(const moq_Level *self); +int8_t moq_Level_partial_cmp(const moq_Level *a, const moq_Level *b); +int8_t moq_Level_cmp(const moq_Level *a, const moq_Level *b); moq_buf moq_Level_to_string(const moq_Level *self); void moq_Park_free(moq_Park *self); void moq_Park_drop(moq_Park *self, moq_status *status); @@ -3095,6 +3118,8 @@ bool moq_Instance_borrowed(const moq_Instance *self); moq_Instance *moq_Instance_clone(const moq_Instance *self, moq_status *status); bool moq_Instance_eq(const moq_Instance *a, const moq_Instance *b, moq_status *status); uint64_t moq_Instance_hash(const moq_Instance *self, moq_status *status); +int8_t moq_Instance_partial_cmp(const moq_Instance *a, const moq_Instance *b, moq_status *status); +int8_t moq_Instance_cmp(const moq_Instance *a, const moq_Instance *b, moq_status *status); moq_buf moq_Instance_to_string(const moq_Instance *self, moq_status *status); moq_buf moq_Instance_debug(const moq_Instance *self, moq_status *status); moq_Instance *moq_Instance_random(void); @@ -3106,6 +3131,8 @@ bool moq_Path_borrowed(const moq_Path *self); moq_Path *moq_Path_clone(const moq_Path *self, moq_status *status); bool moq_Path_eq(const moq_Path *a, const moq_Path *b, moq_status *status); uint64_t moq_Path_hash(const moq_Path *self, moq_status *status); +int8_t moq_Path_partial_cmp(const moq_Path *a, const moq_Path *b, moq_status *status); +int8_t moq_Path_cmp(const moq_Path *a, const moq_Path *b, moq_status *status); moq_buf moq_Path_to_string(const moq_Path *self, moq_status *status); moq_buf moq_Path_debug(const moq_Path *self, moq_status *status); moq_Path *moq_Path_default(void); @@ -3128,6 +3155,8 @@ bool moq_Pattern_borrowed(const moq_Pattern *self); moq_Pattern *moq_Pattern_clone(const moq_Pattern *self, moq_status *status); bool moq_Pattern_eq(const moq_Pattern *a, const moq_Pattern *b, moq_status *status); uint64_t moq_Pattern_hash(const moq_Pattern *self, moq_status *status); +int8_t moq_Pattern_partial_cmp(const moq_Pattern *a, const moq_Pattern *b, moq_status *status); +int8_t moq_Pattern_cmp(const moq_Pattern *a, const moq_Pattern *b, moq_status *status); moq_buf moq_Pattern_to_string(const moq_Pattern *self, moq_status *status); moq_buf moq_Pattern_debug(const moq_Pattern *self, moq_status *status); moq_Pattern *moq_Pattern_default(void); @@ -3304,6 +3333,8 @@ bool moq_Specificity_borrowed(const moq_Specificity *self); moq_Specificity *moq_Specificity_clone(const moq_Specificity *self); bool moq_Specificity_eq(const moq_Specificity *a, const moq_Specificity *b); uint64_t moq_Specificity_hash(const moq_Specificity *self); +int8_t moq_Specificity_partial_cmp(const moq_Specificity *a, const moq_Specificity *b); +int8_t moq_Specificity_cmp(const moq_Specificity *a, const moq_Specificity *b); moq_buf moq_Specificity_debug(const moq_Specificity *self); void moq_clock_Clock_free(moq_clock_Clock *self); bool moq_clock_Clock_borrowed(const moq_clock_Clock *self); @@ -3587,6 +3618,8 @@ bool moq_tokio_Duration_borrowed(const moq_tokio_Duration *self); moq_tokio_Duration *moq_tokio_Duration_clone(const moq_tokio_Duration *self); bool moq_tokio_Duration_eq(const moq_tokio_Duration *a, const moq_tokio_Duration *b); uint64_t moq_tokio_Duration_hash(const moq_tokio_Duration *self); +int8_t moq_tokio_Duration_partial_cmp(const moq_tokio_Duration *a, const moq_tokio_Duration *b); +int8_t moq_tokio_Duration_cmp(const moq_tokio_Duration *a, const moq_tokio_Duration *b); moq_buf moq_tokio_Duration_to_string(const moq_tokio_Duration *self); moq_buf moq_tokio_Duration_debug(const moq_tokio_Duration *self); moq_tokio_Duration *moq_tokio_Duration_default(void); @@ -9254,6 +9287,8 @@ bool moq_Url_borrowed(const moq_Url *self); moq_Url *moq_Url_clone(const moq_Url *self, moq_status *status); bool moq_Url_eq(const moq_Url *a, const moq_Url *b, moq_status *status); uint64_t moq_Url_hash(const moq_Url *self, moq_status *status); +int8_t moq_Url_partial_cmp(const moq_Url *a, const moq_Url *b, moq_status *status); +int8_t moq_Url_cmp(const moq_Url *a, const moq_Url *b, moq_status *status); moq_buf moq_Url_to_string(const moq_Url *self, moq_status *status); moq_buf moq_Url_debug(const moq_Url *self, moq_status *status); bool moq_Url_parse(moq_buf input, moq_Url **out, moq_buf *err); @@ -9266,6 +9301,8 @@ bool moq_Instant_borrowed(const moq_Instant *self); moq_Instant *moq_Instant_clone(const moq_Instant *self); bool moq_Instant_eq(const moq_Instant *a, const moq_Instant *b); uint64_t moq_Instant_hash(const moq_Instant *self); +int8_t moq_Instant_partial_cmp(const moq_Instant *a, const moq_Instant *b); +int8_t moq_Instant_cmp(const moq_Instant *a, const moq_Instant *b); moq_buf moq_Instant_debug(const moq_Instant *self); void moq_rustls_ServerConfig_free(moq_rustls_ServerConfig *self); bool moq_rustls_ServerConfig_borrowed(const moq_rustls_ServerConfig *self); diff --git a/ffi/tests/fixtures/transcript/parse.rs b/ffi/tests/fixtures/transcript/parse.rs index 7fa21bc45..8fecbe780 100644 --- a/ffi/tests/fixtures/transcript/parse.rs +++ b/ffi/tests/fixtures/transcript/parse.rs @@ -1287,6 +1287,7 @@ impl Scope<'_> { fail(c, "`cmp` of no type of the API"); } let b = self.check(&m.args[0], &want); + self.ordered(c, vec![&a, &b]); Expr::new(Kind::Binary(Op::Cmp, Box::new(a), Box::new(b)), Type::Int(Int::I8)) } diff --git a/ffi/tests/fixtures/transcript/swift.rs b/ffi/tests/fixtures/transcript/swift.rs index 43a75dd39..fbecaeb54 100644 --- a/ffi/tests/fixtures/transcript/swift.rs +++ b/ffi/tests/fixtures/transcript/swift.rs @@ -108,9 +108,12 @@ func _fails(_: E.Type, _ body: () throws -> T) -> } } -/// Rust's `Ord` of two values, through `Comparable`. -func _cmp(_ a: T, _ b: T) -> Swift.Int8 { - a < b ? -1 : b < a ? 1 : 0 +/// Rust's `Ord` of two values, through their `<`, which agrees with it and throws where a +/// check of a handle can fail, so a type without `Comparable` orders too. +func _cmp( + _ a: borrowing T, _ b: borrowing T, _ lt: (borrowing T, borrowing T) throws -> Swift.Bool +) rethrows -> Swift.Int8 { + try lt(a, b) ? -1 : try lt(b, a) ? 1 : 0 } "#; @@ -1203,7 +1206,7 @@ impl Emitter<'_> { } let (a, b) = (self.expr(a, out), self.expr(b, out)); let op = match op { - Op::Cmp => return format!("_cmp({a}, {b})"), + Op::Cmp => return format!("_cmp({a}, {b}, <)"), Op::Eq => "==", Op::Ne => "!=", Op::Lt => "<", From b1cf225bfe875caa84e384515d66721a6e79e95f Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Fri, 20 Nov 2026 01:40:44 -0800 Subject: [PATCH 4/9] fix(ffi): lock Go's variant field names, and run Rank through every transcript Co-Authored-By: Claude Opus 5.5 --- ffi/fixtures/api/examples/transcript.rs | 19 +++++++++++++++++++ ffi/src/go.rs | 15 ++++++++++++--- ffi/tests/fixtures/transcript/cpp.rs | 8 +++++++- ffi/tests/fixtures/transcript/dart.rs | 12 +++++++++++- ffi/tests/fixtures/transcript/go.rs | 24 +++++------------------- 5 files changed, 54 insertions(+), 24 deletions(-) diff --git a/ffi/fixtures/api/examples/transcript.rs b/ffi/fixtures/api/examples/transcript.rs index 6d9b508d5..063377bed 100644 --- a/ffi/fixtures/api/examples/transcript.rs +++ b/ffi/fixtures/api/examples/transcript.rs @@ -1042,6 +1042,25 @@ fn main() { t2.cmp(&t1) as i8, t1.cmp(&t1) as i8 ); + // A rank's fields are named as the comparison methods, which each binding keeps apart. + let ranked = api::Rank::Ranked { + compare: 1, + partial_compare: 2, + compare_to: 3, + partial_compare_to: 4, + }; + println!( + "rank {} {} {}", + api::Rank::Unranked < ranked, + ranked.cmp(&api::Rank::Unranked) as i8, + ranked + == api::Rank::Ranked { + compare: 1, + partial_compare: 2, + compare_to: 3, + partial_compare_to: 4 + } + ); println!( "lossless ip {} {}", ip_hex(api::same_ip_addr("255.255.255.255".parse().unwrap())), diff --git a/ffi/src/go.rs b/ffi/src/go.rs index cb644d9f5..8b01a6eee 100644 --- a/ffi/src/go.rs +++ b/ffi/src/go.rs @@ -2048,10 +2048,19 @@ impl<'a> Gen<'a> { } /// The Go names of a data enum's variant's fields, clear of the methods its traits add. - fn variant_fields(&self, i: usize, variant: &Variant) -> Vec { - let mut taken = self.trait_methods(&Type::Enum(i), self.abi.api.enums[i].traits); + fn variant_fields(&mut self, i: usize, variant: &Variant) -> Vec { + let e = &self.abi.api.enums[i]; + let mut taken = self.trait_methods(&Type::Enum(i), e.traits); + let owner = crate::lock::type_key(&e.shown); (variant.fields.iter()) - .map(|f| unique(&mut taken, field_name(&f.name))) + .map(|f| { + let name = unique(&mut taken, field_name(&f.name)); + self.locked.insert( + format!("{owner} / variant {} / field {}", variant.name, f.name), + name.clone(), + ); + name + }) .collect() } diff --git a/ffi/tests/fixtures/transcript/cpp.rs b/ffi/tests/fixtures/transcript/cpp.rs index 9e47d04c0..4f51af542 100644 --- a/ffi/tests/fixtures/transcript/cpp.rs +++ b/ffi/tests/fixtures/transcript/cpp.rs @@ -1213,9 +1213,15 @@ impl Emitter<'_> { } Kind::IsSome(inner) => format!("{}.has_value()", self.value(inner, &inner.ty, Place::Read)), Kind::Binary(op, a, b) => { + if *op == Op::Cmp { + // A data enum's variant is a type of its own, so `cmp` names the enum's. + let of = self.ctype(unref(&a.ty).base()); + let (a, b) = (self.value(a, &a.ty, Place::Read), self.value(b, &b.ty, Place::Read)); + return format!("rs::cmp<{of}>({a}, {b})"); + } let (a, b) = (self.value(a, &a.ty, Place::Read), self.value(b, &b.ty, Place::Read)); let (op, arithmetic) = match op { - Op::Cmp => return format!("rs::cmp({a}, {b})"), + Op::Cmp => unreachable!("`cmp` returned above"), Op::Eq => ("==", false), Op::Ne => ("!=", false), Op::Lt => ("<", false), diff --git a/ffi/tests/fixtures/transcript/dart.rs b/ffi/tests/fixtures/transcript/dart.rs index 1e4b88e3b..b0fe681bb 100644 --- a/ffi/tests/fixtures/transcript/dart.rs +++ b/ffi/tests/fixtures/transcript/dart.rs @@ -304,7 +304,17 @@ fn member(name: &str, taken: &[&str]) -> String { /// A record's field, as the exporter names it. fn field(name: &str) -> String { - member(name, &["hashCode", "noSuchMethod", "runtimeType", "toString"]) + member( + name, + &[ + "hashCode", + "noSuchMethod", + "runtimeType", + "toString", + "compareTo", + "partialCompareTo", + ], + ) } /// The Dart of an integer's name, as the runtime's classes end in it: `u64` is `U64`. diff --git a/ffi/tests/fixtures/transcript/go.rs b/ffi/tests/fixtures/transcript/go.rs index 09637fd47..187097aae 100644 --- a/ffi/tests/fixtures/transcript/go.rs +++ b/ffi/tests/fixtures/transcript/go.rs @@ -984,10 +984,11 @@ impl Emitter<'_> { if enumeration.variants.iter().all(|v| v.fields.is_empty()) { return format!("{package}.{name}"); } - let named: Vec<(String, Type)> = variant - .fields - .iter() - .map(|f| (field_name(&f.name), f.ty.clone())) + let named: Vec<(String, Type)> = (variant.fields.iter()) + .map(|f| { + let key = format!("type {rust} / variant {} / field {}", variant.name, f.name); + (self.t.named(LANGUAGE, &key).to_string(), f.ty.clone()) + }) .collect(); let values: Vec = (fields.iter().zip(&named)) .map(|(f, (name, ty))| { @@ -1805,21 +1806,6 @@ fn pascal_int(int: Int) -> String { format!("{first}{}", chars.as_str()) } -/// A field's Go name, as the export spells a variant's: `V0` for a positional one. -fn field_name(name: &str) -> String { - match name.starts_with(|c: char| c.is_ascii_digit()) { - true => format!("V{name}"), - false => { - let camel = local(name); - let mut chars = camel.chars(); - match chars.next() { - Some(first) => first.to_uppercase().chain(chars).collect(), - None => String::new(), - } - } - } -} - /// A Go string literal. fn string(s: &str) -> String { let mut out = String::from("\""); From d7a3a7585f2a258d15e4a33bc6f7a9c2776e63d2 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Fri, 20 Nov 2026 02:01:29 -0800 Subject: [PATCH 5/9] ffi: regenerate surface after merging #898 Co-Authored-By: Claude Opus 5.5 --- ffi/surface/api/c.h | 61 ++++++++++++++++++++++++++++++++++++++++++++- ffi/surface/moq/c.h | 39 ++++++++++++++++++++++++++++- 2 files changed, 98 insertions(+), 2 deletions(-) diff --git a/ffi/surface/api/c.h b/ffi/surface/api/c.h index de57d244d..8b289f690 100644 --- a/ffi/surface/api/c.h +++ b/ffi/surface/api/c.h @@ -17,7 +17,7 @@ #ifdef __cplusplus extern "C" { #endif -#define API_CONTRACT ((uint64_t)0x90b55a88885e2638ULL) +#define API_CONTRACT ((uint64_t)0xeb005b408519187fULL) uint64_t api_contract(void); uint32_t api_target(void); typedef int32_t api_status; @@ -156,6 +156,8 @@ typedef struct api_Stack api_Stack; typedef struct api_Refusal api_Refusal; typedef struct api_Fault api_Fault; typedef struct api_c api_c; +typedef struct api_Quantity api_Quantity; +typedef struct api_Pass api_Pass; typedef struct api_Key api_Key; typedef struct api_clash_Seed api_clash_Seed; typedef struct api_clash_Empty_string api_clash_Empty_string; @@ -190,6 +192,10 @@ typedef enum api_Family { typedef enum api_VecClashTone { API_VECCLASHTONE_ERROR = 0, } api_VecClashTone; +typedef enum api_Tier { + API_TIER_LOW = 0, + API_TIER_HIGH = 1, +} api_Tier; typedef enum api_Level { API_LEVEL_TRACE = 0, API_LEVEL_DEBUG = 1, @@ -825,6 +831,10 @@ typedef struct api_Qualifiers { double api; double kotlin; } api_Qualifiers; +typedef struct api_Version { + uint16_t major; + uint16_t minor; +} api_Version; typedef struct api_Spot { uint32_t x; uint32_t y; @@ -1078,6 +1088,22 @@ typedef struct api_Builtin { api_Builtin_Native native; }; } api_Builtin; +typedef enum api_Rank_tag { + API_RANK_UNRANKED = 0, + API_RANK_RANKED = 1, +} api_Rank_tag; +typedef struct api_Rank_Ranked { + uint8_t compare; + uint8_t partial_compare; + uint8_t compare_to; + uint8_t partial_compare_to; +} api_Rank_Ranked; +typedef struct api_Rank { + api_Rank_tag tag; + union { + api_Rank_Ranked ranked; + }; +} api_Rank; typedef enum api_clash_Candidate_tag { API_CLASH_CANDIDATE_NONE = 0, API_CLASH_CANDIDATE_MATCH = 1, @@ -1339,6 +1365,11 @@ bool api_a_eq(const api_a *a, const api_a *b); API_MUST_USE api_buf api_a_debug(const api_a *self); void api_Qualifiers_free(api_Qualifiers *self); bool api_Qualifiers_eq(const api_Qualifiers *a, const api_Qualifiers *b); +void api_Version_free(api_Version *self); +bool api_Version_eq(const api_Version *a, const api_Version *b); +int8_t api_Version_partial_cmp(const api_Version *a, const api_Version *b); +int8_t api_Version_cmp(const api_Version *a, const api_Version *b); +API_MUST_USE api_buf api_Version_debug(const api_Version *self); void api_Spot_free(api_Spot *self); bool api_Spot_eq(const api_Spot *a, const api_Spot *b); API_MUST_USE api_buf api_Spot_debug(const api_Spot *self); @@ -1445,11 +1476,22 @@ bool api_b_eq(const api_b *a, const api_b *b); API_MUST_USE api_buf api_b_debug(const api_b *self); void api_Builtin_free(api_Builtin *self); bool api_Builtin_eq(const api_Builtin *a, const api_Builtin *b); +void api_Rank_free(api_Rank *self); +bool api_Rank_eq(const api_Rank *a, const api_Rank *b); +int8_t api_Rank_partial_cmp(const api_Rank *a, const api_Rank *b); +int8_t api_Rank_cmp(const api_Rank *a, const api_Rank *b); +API_MUST_USE api_buf api_Rank_debug(const api_Rank *self); +bool api_Tier_eq(const api_Tier *a, const api_Tier *b); +int8_t api_Tier_partial_cmp(const api_Tier *a, const api_Tier *b); +int8_t api_Tier_cmp(const api_Tier *a, const api_Tier *b); +API_MUST_USE api_buf api_Tier_debug(const api_Tier *self); void api_clash_Candidate_free(api_clash_Candidate *self); bool api_clash_Candidate_eq(const api_clash_Candidate *a, const api_clash_Candidate *b); API_MUST_USE api_buf api_clash_Candidate_debug(const api_clash_Candidate *self); bool api_Level_eq(const api_Level *a, const api_Level *b); uint64_t api_Level_hash(const api_Level *self); +int8_t api_Level_partial_cmp(const api_Level *a, const api_Level *b); +int8_t api_Level_cmp(const api_Level *a, const api_Level *b); API_MUST_USE api_buf api_Level_to_string(const api_Level *self); void api_Board_free(api_Board *self); void api_Board_drop(api_Board *self, api_status *status); @@ -1939,6 +1981,19 @@ void api_c_free(api_c *self); bool api_c_eq(const api_c *a, const api_c *b); API_MUST_USE api_buf api_c_debug(const api_c *self); API_MUST_USE api_c *api_c_new(uint8_t value); +void api_Quantity_free(api_Quantity *self); +bool api_Quantity_eq(const api_Quantity *a, const api_Quantity *b); +int8_t api_Quantity_partial_cmp(const api_Quantity *a, const api_Quantity *b); +API_MUST_USE api_buf api_Quantity_debug(const api_Quantity *self); +API_MUST_USE api_Quantity *api_Quantity_new(int64_t value, uint32_t unit); +void api_Pass_free(api_Pass *self); +void api_Pass_drop(api_Pass *self, api_status *status); +bool api_Pass_eq(const api_Pass *a, const api_Pass *b, api_status *status); +int8_t api_Pass_partial_cmp(const api_Pass *a, const api_Pass *b, api_status *status); +int8_t api_Pass_cmp(const api_Pass *a, const api_Pass *b, api_status *status); +API_MUST_USE api_buf api_Pass_debug(const api_Pass *self, api_status *status); +API_MUST_USE api_Pass *api_Pass_new(uint32_t number); +uint32_t api_Pass_redeem(api_Pass *self, api_status *status); void api_Key_free(api_Key *self); bool api_Key_borrowed(const api_Key *self); API_MUST_USE api_Key *api_Key_clone(const api_Key *self); @@ -1967,6 +2022,8 @@ bool api_Url_borrowed(const api_Url *self); API_MUST_USE api_Url *api_Url_clone(const api_Url *self, api_status *status); bool api_Url_eq(const api_Url *a, const api_Url *b, api_status *status); uint64_t api_Url_hash(const api_Url *self, api_status *status); +int8_t api_Url_partial_cmp(const api_Url *a, const api_Url *b, api_status *status); +int8_t api_Url_cmp(const api_Url *a, const api_Url *b, api_status *status); API_MUST_USE api_buf api_Url_to_string(const api_Url *self, api_status *status); API_MUST_USE api_buf api_Url_debug(const api_Url *self, api_status *status); API_MUST_USE bool api_Url_parse(api_buf input, api_Url **out, api_buf *err); @@ -1979,6 +2036,8 @@ bool api_Instant_borrowed(const api_Instant *self); API_MUST_USE api_Instant *api_Instant_clone(const api_Instant *self); bool api_Instant_eq(const api_Instant *a, const api_Instant *b); uint64_t api_Instant_hash(const api_Instant *self); +int8_t api_Instant_partial_cmp(const api_Instant *a, const api_Instant *b); +int8_t api_Instant_cmp(const api_Instant *a, const api_Instant *b); API_MUST_USE api_buf api_Instant_debug(const api_Instant *self); void api_std_io_Error_free(api_std_io_Error *self); void api_std_io_Error_drop(api_std_io_Error *self, api_status *status); diff --git a/ffi/surface/moq/c.h b/ffi/surface/moq/c.h index 150b7e064..add874d44 100644 --- a/ffi/surface/moq/c.h +++ b/ffi/surface/moq/c.h @@ -17,7 +17,7 @@ #ifdef __cplusplus extern "C" { #endif -#define MOQ_CONTRACT ((uint64_t)0x797d794629bfbf19ULL) +#define MOQ_CONTRACT ((uint64_t)0x795cd35cc0fc5623ULL) uint64_t moq_contract(void); uint32_t moq_target(void); typedef int32_t moq_status; @@ -2350,6 +2350,8 @@ MOQ_MUST_USE moq_buf moq_TimeOverflow_to_string(const moq_TimeOverflow *self); MOQ_MUST_USE moq_buf moq_TimeOverflow_debug(const moq_TimeOverflow *self); bool moq_Timescale_eq(const moq_Timescale *a, const moq_Timescale *b); uint64_t moq_Timescale_hash(const moq_Timescale *self); +int8_t moq_Timescale_partial_cmp(const moq_Timescale *a, const moq_Timescale *b); +int8_t moq_Timescale_cmp(const moq_Timescale *a, const moq_Timescale *b); MOQ_MUST_USE moq_buf moq_Timescale_to_string(const moq_Timescale *self); MOQ_MUST_USE moq_buf moq_Timescale_debug(const moq_Timescale *self); moq_Timescale moq_Timescale_SECOND(void); @@ -2360,6 +2362,7 @@ MOQ_MUST_USE bool moq_Timescale_new(uint64_t units_per_second, moq_Timescale *ou uint64_t moq_Timescale_as_u64(const moq_Timescale *self); bool moq_Timestamp_eq(const moq_Timestamp *a, const moq_Timestamp *b); uint64_t moq_Timestamp_hash(const moq_Timestamp *self); +int8_t moq_Timestamp_partial_cmp(const moq_Timestamp *a, const moq_Timestamp *b); MOQ_MUST_USE moq_buf moq_Timestamp_debug(const moq_Timestamp *self); moq_Timestamp moq_Timestamp_ZERO(void); MOQ_MUST_USE bool moq_Timestamp_new(uint64_t value, moq_Timescale scale, moq_Timestamp *out, moq_TimeOverflow *err); @@ -2382,6 +2385,8 @@ MOQ_MUST_USE bool moq_Timestamp_checked_add(const moq_Timestamp *self, moq_Times MOQ_MUST_USE bool moq_Timestamp_checked_sub(const moq_Timestamp *self, moq_Timestamp rhs, moq_Timestamp *out, moq_TimeOverflow *err); bool moq_clock_Instant_eq(const moq_clock_Instant *a, const moq_clock_Instant *b); uint64_t moq_clock_Instant_hash(const moq_clock_Instant *self); +int8_t moq_clock_Instant_partial_cmp(const moq_clock_Instant *a, const moq_clock_Instant *b); +int8_t moq_clock_Instant_cmp(const moq_clock_Instant *a, const moq_clock_Instant *b); MOQ_MUST_USE moq_buf moq_clock_Instant_debug(const moq_clock_Instant *self); moq_clock_Instant moq_clock_Instant_ZERO(void); moq_clock_Instant moq_clock_Instant_now(void); @@ -2400,6 +2405,8 @@ MOQ_MUST_USE moq_buf moq_clock_Elapsed_to_string(const moq_clock_Elapsed *self); MOQ_MUST_USE moq_buf moq_clock_Elapsed_debug(const moq_clock_Elapsed *self); bool moq_clock_Wall_eq(const moq_clock_Wall *a, const moq_clock_Wall *b); uint64_t moq_clock_Wall_hash(const moq_clock_Wall *self); +int8_t moq_clock_Wall_partial_cmp(const moq_clock_Wall *a, const moq_clock_Wall *b); +int8_t moq_clock_Wall_cmp(const moq_clock_Wall *a, const moq_clock_Wall *b); MOQ_MUST_USE moq_buf moq_clock_Wall_debug(const moq_clock_Wall *self); moq_clock_Wall moq_clock_Wall_UNIX_EPOCH(void); moq_clock_Wall moq_clock_Wall_MOQ_EPOCH(void); @@ -2618,6 +2625,8 @@ moq_option_non_zero_u64 moq_transport_Limits_receive_window_get(const moq_transp void moq_transport_Limits_receive_window_set(moq_transport_Limits *self, moq_option_non_zero_u64 value); bool moq_bandwidth_Rate_eq(const moq_bandwidth_Rate *a, const moq_bandwidth_Rate *b); uint64_t moq_bandwidth_Rate_hash(const moq_bandwidth_Rate *self); +int8_t moq_bandwidth_Rate_partial_cmp(const moq_bandwidth_Rate *a, const moq_bandwidth_Rate *b); +int8_t moq_bandwidth_Rate_cmp(const moq_bandwidth_Rate *a, const moq_bandwidth_Rate *b); MOQ_MUST_USE moq_buf moq_bandwidth_Rate_debug(const moq_bandwidth_Rate *self); moq_bandwidth_Rate moq_bandwidth_Rate_default(void); moq_bandwidth_Rate moq_bandwidth_Rate_ZERO(void); @@ -2635,6 +2644,8 @@ MOQ_MUST_USE moq_buf moq_frame_Info_debug(const moq_frame_Info *self); void moq_group_Info_free(moq_group_Info *self); bool moq_group_Info_eq(const moq_group_Info *a, const moq_group_Info *b); uint64_t moq_group_Info_hash(const moq_group_Info *self); +int8_t moq_group_Info_partial_cmp(const moq_group_Info *a, const moq_group_Info *b); +int8_t moq_group_Info_cmp(const moq_group_Info *a, const moq_group_Info *b); MOQ_MUST_USE moq_buf moq_group_Info_debug(const moq_group_Info *self); void moq_track_Delay_free(moq_track_Delay *self); bool moq_track_Delay_eq(const moq_track_Delay *a, const moq_track_Delay *b); @@ -2644,6 +2655,8 @@ moq_track_Delay moq_track_Delay_with_min(const moq_track_Delay *self, moq_option moq_track_Delay moq_track_Delay_with_max(const moq_track_Delay *self, moq_option_duration max); bool moq_track_Position_eq(const moq_track_Position *a, const moq_track_Position *b); uint64_t moq_track_Position_hash(const moq_track_Position *self); +int8_t moq_track_Position_partial_cmp(const moq_track_Position *a, const moq_track_Position *b); +int8_t moq_track_Position_cmp(const moq_track_Position *a, const moq_track_Position *b); MOQ_MUST_USE moq_buf moq_track_Position_debug(const moq_track_Position *self); moq_track_Position moq_track_Position_default(void); uint64_t moq_track_Position_group_get(const moq_track_Position *self); @@ -2655,16 +2668,22 @@ moq_track_Position moq_track_Position_group(uint64_t group); void moq_track_Range_free(moq_track_Range *self); bool moq_track_Range_eq(const moq_track_Range *a, const moq_track_Range *b); uint64_t moq_track_Range_hash(const moq_track_Range *self); +int8_t moq_track_Range_partial_cmp(const moq_track_Range *a, const moq_track_Range *b); +int8_t moq_track_Range_cmp(const moq_track_Range *a, const moq_track_Range *b); MOQ_MUST_USE moq_buf moq_track_Range_debug(const moq_track_Range *self); moq_track_Range moq_track_Range_live(void); moq_track_Range moq_track_Range_oldest(void); bool moq_origin_Cost_eq(const moq_origin_Cost *a, const moq_origin_Cost *b); +int8_t moq_origin_Cost_partial_cmp(const moq_origin_Cost *a, const moq_origin_Cost *b); +int8_t moq_origin_Cost_cmp(const moq_origin_Cost *a, const moq_origin_Cost *b); MOQ_MUST_USE moq_buf moq_origin_Cost_debug(const moq_origin_Cost *self); moq_origin_Cost moq_origin_Cost_default(void); moq_origin_Cost moq_origin_Cost_new(uint64_t cost); uint64_t moq_origin_Cost_value(const moq_origin_Cost *self); bool moq_origin_Priority_eq(const moq_origin_Priority *a, const moq_origin_Priority *b); uint64_t moq_origin_Priority_hash(const moq_origin_Priority *self); +int8_t moq_origin_Priority_partial_cmp(const moq_origin_Priority *a, const moq_origin_Priority *b); +int8_t moq_origin_Priority_cmp(const moq_origin_Priority *a, const moq_origin_Priority *b); MOQ_MUST_USE moq_buf moq_origin_Priority_debug(const moq_origin_Priority *self); moq_origin_Priority moq_origin_Priority_default(void); moq_origin_Priority moq_origin_Priority_new(int8_t priority); @@ -2880,6 +2899,8 @@ moq_track_Compression moq_track_Compression_default(void); void moq_track_Anchor_free(moq_track_Anchor *self); bool moq_track_Anchor_eq(const moq_track_Anchor *a, const moq_track_Anchor *b); uint64_t moq_track_Anchor_hash(const moq_track_Anchor *self); +int8_t moq_track_Anchor_partial_cmp(const moq_track_Anchor *a, const moq_track_Anchor *b); +int8_t moq_track_Anchor_cmp(const moq_track_Anchor *a, const moq_track_Anchor *b); MOQ_MUST_USE moq_buf moq_track_Anchor_debug(const moq_track_Anchor *self); bool moq_track_Order_eq(const moq_track_Order *a, const moq_track_Order *b); uint64_t moq_track_Order_hash(const moq_track_Order *self); @@ -3059,6 +3080,8 @@ MOQ_MUST_USE moq_buf moq_moq_sock_udp_EcnCodepoint_debug(const moq_moq_sock_udp_ moq_option_moq_sock_udp_EcnCodepoint moq_moq_sock_udp_EcnCodepoint_from_bits(uint8_t x); bool moq_Level_eq(const moq_Level *a, const moq_Level *b); uint64_t moq_Level_hash(const moq_Level *self); +int8_t moq_Level_partial_cmp(const moq_Level *a, const moq_Level *b); +int8_t moq_Level_cmp(const moq_Level *a, const moq_Level *b); MOQ_MUST_USE moq_buf moq_Level_to_string(const moq_Level *self); void moq_Park_free(moq_Park *self); void moq_Park_drop(moq_Park *self, moq_status *status); @@ -3105,6 +3128,8 @@ bool moq_Instance_borrowed(const moq_Instance *self); MOQ_MUST_USE moq_Instance *moq_Instance_clone(const moq_Instance *self, moq_status *status); bool moq_Instance_eq(const moq_Instance *a, const moq_Instance *b, moq_status *status); uint64_t moq_Instance_hash(const moq_Instance *self, moq_status *status); +int8_t moq_Instance_partial_cmp(const moq_Instance *a, const moq_Instance *b, moq_status *status); +int8_t moq_Instance_cmp(const moq_Instance *a, const moq_Instance *b, moq_status *status); MOQ_MUST_USE moq_buf moq_Instance_to_string(const moq_Instance *self, moq_status *status); MOQ_MUST_USE moq_buf moq_Instance_debug(const moq_Instance *self, moq_status *status); MOQ_MUST_USE moq_Instance *moq_Instance_random(void); @@ -3116,6 +3141,8 @@ bool moq_Path_borrowed(const moq_Path *self); MOQ_MUST_USE moq_Path *moq_Path_clone(const moq_Path *self, moq_status *status); bool moq_Path_eq(const moq_Path *a, const moq_Path *b, moq_status *status); uint64_t moq_Path_hash(const moq_Path *self, moq_status *status); +int8_t moq_Path_partial_cmp(const moq_Path *a, const moq_Path *b, moq_status *status); +int8_t moq_Path_cmp(const moq_Path *a, const moq_Path *b, moq_status *status); MOQ_MUST_USE moq_buf moq_Path_to_string(const moq_Path *self, moq_status *status); MOQ_MUST_USE moq_buf moq_Path_debug(const moq_Path *self, moq_status *status); MOQ_MUST_USE moq_Path *moq_Path_default(void); @@ -3138,6 +3165,8 @@ bool moq_Pattern_borrowed(const moq_Pattern *self); MOQ_MUST_USE moq_Pattern *moq_Pattern_clone(const moq_Pattern *self, moq_status *status); bool moq_Pattern_eq(const moq_Pattern *a, const moq_Pattern *b, moq_status *status); uint64_t moq_Pattern_hash(const moq_Pattern *self, moq_status *status); +int8_t moq_Pattern_partial_cmp(const moq_Pattern *a, const moq_Pattern *b, moq_status *status); +int8_t moq_Pattern_cmp(const moq_Pattern *a, const moq_Pattern *b, moq_status *status); MOQ_MUST_USE moq_buf moq_Pattern_to_string(const moq_Pattern *self, moq_status *status); MOQ_MUST_USE moq_buf moq_Pattern_debug(const moq_Pattern *self, moq_status *status); MOQ_MUST_USE moq_Pattern *moq_Pattern_default(void); @@ -3314,6 +3343,8 @@ bool moq_Specificity_borrowed(const moq_Specificity *self); MOQ_MUST_USE moq_Specificity *moq_Specificity_clone(const moq_Specificity *self); bool moq_Specificity_eq(const moq_Specificity *a, const moq_Specificity *b); uint64_t moq_Specificity_hash(const moq_Specificity *self); +int8_t moq_Specificity_partial_cmp(const moq_Specificity *a, const moq_Specificity *b); +int8_t moq_Specificity_cmp(const moq_Specificity *a, const moq_Specificity *b); MOQ_MUST_USE moq_buf moq_Specificity_debug(const moq_Specificity *self); void moq_clock_Clock_free(moq_clock_Clock *self); bool moq_clock_Clock_borrowed(const moq_clock_Clock *self); @@ -3597,6 +3628,8 @@ bool moq_tokio_Duration_borrowed(const moq_tokio_Duration *self); MOQ_MUST_USE moq_tokio_Duration *moq_tokio_Duration_clone(const moq_tokio_Duration *self); bool moq_tokio_Duration_eq(const moq_tokio_Duration *a, const moq_tokio_Duration *b); uint64_t moq_tokio_Duration_hash(const moq_tokio_Duration *self); +int8_t moq_tokio_Duration_partial_cmp(const moq_tokio_Duration *a, const moq_tokio_Duration *b); +int8_t moq_tokio_Duration_cmp(const moq_tokio_Duration *a, const moq_tokio_Duration *b); MOQ_MUST_USE moq_buf moq_tokio_Duration_to_string(const moq_tokio_Duration *self); MOQ_MUST_USE moq_buf moq_tokio_Duration_debug(const moq_tokio_Duration *self); MOQ_MUST_USE moq_tokio_Duration *moq_tokio_Duration_default(void); @@ -9264,6 +9297,8 @@ bool moq_Url_borrowed(const moq_Url *self); MOQ_MUST_USE moq_Url *moq_Url_clone(const moq_Url *self, moq_status *status); bool moq_Url_eq(const moq_Url *a, const moq_Url *b, moq_status *status); uint64_t moq_Url_hash(const moq_Url *self, moq_status *status); +int8_t moq_Url_partial_cmp(const moq_Url *a, const moq_Url *b, moq_status *status); +int8_t moq_Url_cmp(const moq_Url *a, const moq_Url *b, moq_status *status); MOQ_MUST_USE moq_buf moq_Url_to_string(const moq_Url *self, moq_status *status); MOQ_MUST_USE moq_buf moq_Url_debug(const moq_Url *self, moq_status *status); MOQ_MUST_USE bool moq_Url_parse(moq_buf input, moq_Url **out, moq_buf *err); @@ -9276,6 +9311,8 @@ bool moq_Instant_borrowed(const moq_Instant *self); MOQ_MUST_USE moq_Instant *moq_Instant_clone(const moq_Instant *self); bool moq_Instant_eq(const moq_Instant *a, const moq_Instant *b); uint64_t moq_Instant_hash(const moq_Instant *self); +int8_t moq_Instant_partial_cmp(const moq_Instant *a, const moq_Instant *b); +int8_t moq_Instant_cmp(const moq_Instant *a, const moq_Instant *b); MOQ_MUST_USE moq_buf moq_Instant_debug(const moq_Instant *self); void moq_rustls_ServerConfig_free(moq_rustls_ServerConfig *self); bool moq_rustls_ServerConfig_borrowed(const moq_rustls_ServerConfig *self); From 3c70d0c616cfab98cd086614f8c6c24cc576fa6c Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Fri, 20 Nov 2026 02:03:34 -0800 Subject: [PATCH 6/9] fix(ffi)!: number tracing's Level in its Ord, and keep Dart's enum constants clear of comparison methods Level's C values now run ERROR (0) to TRACE (4), so C's and Go's `<`, C++'s, and Kotlin's final enum `compareTo` agree with Rust's `Ord`. Co-Authored-By: Claude Opus 5.5 --- ffi/README.md | 2 +- ffi/fixtures/api/examples/transcript.rs | 3 ++- ffi/fixtures/api/src/lib.rs | 3 +++ ffi/src/collect.rs | 7 ++++--- ffi/src/dart.rs | 5 ++++- ffi/tests/fixtures/transcript/dart.rs | 5 ++++- 6 files changed, 18 insertions(+), 7 deletions(-) diff --git a/ffi/README.md b/ffi/README.md index 05e3db123..d1db0c811 100644 --- a/ffi/README.md +++ b/ffi/README.md @@ -124,7 +124,7 @@ public path names, or an error taken by value, is held by value as an opaque han | a type implementing `PartialEq` and `Hash` | beside `_eq`, `uint64_t _hash`, its `Hash` through std's hasher with its fixed keys, so equal values hash alike in every binding | | a type implementing `PartialOrd` with itself | `int8_t _partial_cmp(a, b)`: -1, 0, or 1 as `a` is less than, equal to, or greater than `b`, or 2 when the two are unordered; with `Ord`, `int8_t _cmp(a, b)` too, -1, 0, or 1. Every binding's `<` and its kin call `_partial_cmp`, as Rust's do, and its total order, where it has one, `_cmp` | | `std::time::Instant` | an object `_Instant`, which only Rust makes, copied into each call that takes it and compared by `_eq` and ordered by `_cmp`, with none of its methods | -| `tracing::Level` | `_Level`: a C enum of its five levels, `TRACE` to `ERROR`, ordered by tracing's `Ord`, the more verbose after the less | +| `tracing::Level` | `_Level`: a C enum of its five levels, `ERROR` (0) to `TRACE` (4), numbered in tracing's `Ord`, the more verbose after the less, so every language's own order of it agrees with Rust's | | `tracing::level_filters::LevelFilter` | `Option`, whose `None` is `OFF` | | `serde_json::Value` | an object `_Json`, made by `_Json_parse` from JSON text, which fails with serde_json's message, and read back by `_to_text`; its contents are the caller's JSON library's to read | | `Vec`, `&[T]`, and `Box<[T]>` of any other `T` | `_vec_`: an array of `T`'s C values, viewed passed in and owned returned, a slice as a clone; of references only returned; a boxed slice of bytes is refused | diff --git a/ffi/fixtures/api/examples/transcript.rs b/ffi/fixtures/api/examples/transcript.rs index 063377bed..8a3d54eb7 100644 --- a/ffi/fixtures/api/examples/transcript.rs +++ b/ffi/fixtures/api/examples/transcript.rs @@ -1026,8 +1026,9 @@ fn main() { m1 >= g1 ); println!( - "tier {} {} {} {}", + "tier {} {} {} {} {}", Tier::Low < Tier::High, + Tier::CompareTo < Tier::PartialCompareTo, Tier::Low >= Tier::Low, Tier::High.cmp(&Tier::Low) as i8, Tier::Low.cmp(&Tier::High) as i8 diff --git a/ffi/fixtures/api/src/lib.rs b/ffi/fixtures/api/src/lib.rs index 9ea50709d..799e21503 100644 --- a/ffi/fixtures/api/src/lib.rs +++ b/ffi/fixtures/api/src/lib.rs @@ -5153,6 +5153,9 @@ pub enum Rank { pub enum Tier { Low, High, + /// Named as Dart's comparison methods are, which its constants keep apart. + CompareTo, + PartialCompareTo, } /// A key: an object whose `Hash` agrees with its `PartialEq`, so a binding hashes it by diff --git a/ffi/src/collect.rs b/ffi/src/collect.rs index 1312638b7..435cf05f1 100644 --- a/ffi/src/collect.rs +++ b/ffi/src/collect.rs @@ -1858,7 +1858,9 @@ impl<'tcx> Collector<'tcx> { if let Some(level) = &mut self.level { level.index = self.api.enums.len(); let def_id = level.level; - let variants = ["Trace", "Debug", "Info", "Warn", "Error"]; + // Numbered in its `Ord`, the less verbose first, so each language's own order of + // the enum, such as C's `<` or Kotlin's final `compareTo`, agrees with Rust's. + let variants = ["Error", "Warn", "Info", "Debug", "Trace"]; self.api.enums.push(Enum { path: vec![tcx.crate_name(def_id.krate).to_string(), "Level".to_string()], home: Home { @@ -1869,7 +1871,7 @@ impl<'tcx> Collector<'tcx> { args: Vec::new(), span: tcx.def_span(def_id), on: On::ALL, - docs: "`tracing::Level`: how verbose a span or event is, from the most to the least.".to_string(), + docs: "`tracing::Level`: how verbose a span or event is, from the least to the most.".to_string(), deprecated: None, variants: (variants.iter().zip(0..)) .map(|(name, discriminant)| Variant { @@ -1885,7 +1887,6 @@ impl<'tcx> Collector<'tcx> { methods: Vec::new(), // Its `Debug` is left out: Dart would name it as it names the `Debug` level, // and it prints only what `Display` and the variant's name already say. - // Its `Ord` puts the more verbose level after the less. traits: Traits { clone: true, eq: true, diff --git a/ffi/src/dart.rs b/ffi/src/dart.rs index 034a94b7c..2c30fa503 100644 --- a/ffi/src/dart.rs +++ b/ffi/src/dart.rs @@ -3014,7 +3014,10 @@ fn param_name(name: &str) -> String { /// A plain enum's value: its variant in camel case. fn enum_value(variant: &str) -> String { - member(&abi::snake(variant), &["values", "index", "name"]) + member( + &abi::snake(variant), + &["values", "index", "name", "compareTo", "partialCompareTo"], + ) } /// Whether the members `a` and `b` of one type clash, each `static x`, `new x` for a diff --git a/ffi/tests/fixtures/transcript/dart.rs b/ffi/tests/fixtures/transcript/dart.rs index b0fe681bb..8f6da7eb0 100644 --- a/ffi/tests/fixtures/transcript/dart.rs +++ b/ffi/tests/fixtures/transcript/dart.rs @@ -819,7 +819,10 @@ impl Emitter<'_> { if enumeration.variants.iter().all(|v| v.fields.is_empty()) { return format!( "api.{name}.{}", - member(&snake(&variant.name), &["values", "index", "name"]) + member( + &snake(&variant.name), + &["values", "index", "name", "compareTo", "partialCompareTo"] + ) ); } let key = format!("type {} / variant {}", self.t.rust(&Type::Enum(*en)), variant.name); From 14d784f11ffa6d3f882ce8a547e2874fab3aa454 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Fri, 20 Nov 2026 02:21:54 -0800 Subject: [PATCH 7/9] ffi: regenerate surface after merging #895 Co-Authored-By: Claude Opus 5.5 --- ffi/surface/api/c.h | 12 +-- ffi/surface/api/cpp.hpp | 10 ++- ffi/surface/api/dart.dart | 10 ++- ffi/surface/api/go.txt | 14 ++-- ffi/surface/api/kotlin.kt | 12 +-- ffi/surface/api/python.pyi | 10 ++- ffi/surface/api/swift.swift | 10 ++- ffi/surface/api/web.d.ts | 4 +- ffi/surface/moq/c.h | 10 +-- ffi/surface/moq/cpp.hpp | 8 +- ffi/surface/moq/dart.dart | 157 +++++++++++++++++++++++++++++++----- ffi/surface/moq/go.txt | 8 +- ffi/surface/moq/kotlin.kt | 8 +- ffi/surface/moq/python.pyi | 8 +- ffi/surface/moq/swift.swift | 8 +- 15 files changed, 208 insertions(+), 81 deletions(-) diff --git a/ffi/surface/api/c.h b/ffi/surface/api/c.h index 8b289f690..a522fb087 100644 --- a/ffi/surface/api/c.h +++ b/ffi/surface/api/c.h @@ -17,7 +17,7 @@ #ifdef __cplusplus extern "C" { #endif -#define API_CONTRACT ((uint64_t)0xeb005b408519187fULL) +#define API_CONTRACT ((uint64_t)0x9addadd9264acb2eULL) uint64_t api_contract(void); uint32_t api_target(void); typedef int32_t api_status; @@ -195,13 +195,15 @@ typedef enum api_VecClashTone { typedef enum api_Tier { API_TIER_LOW = 0, API_TIER_HIGH = 1, + API_TIER_COMPARE_TO = 2, + API_TIER_PARTIAL_COMPARE_TO = 3, } api_Tier; typedef enum api_Level { - API_LEVEL_TRACE = 0, - API_LEVEL_DEBUG = 1, + API_LEVEL_ERROR = 0, + API_LEVEL_WARN = 1, API_LEVEL_INFO = 2, - API_LEVEL_WARN = 3, - API_LEVEL_ERROR = 4, + API_LEVEL_DEBUG = 3, + API_LEVEL_TRACE = 4, } api_Level; typedef enum api_bound { API_BOUND_UNBOUNDED = 0, diff --git a/ffi/surface/api/cpp.hpp b/ffi/surface/api/cpp.hpp index 025cd851a..a1a8fd9bb 100644 --- a/ffi/surface/api/cpp.hpp +++ b/ffi/surface/api/cpp.hpp @@ -35,6 +35,8 @@ namespace api { enum class Tier { low = 0, high = 1, + compare_to = 2, + partial_compare_to = 3, }; inline constexpr ::std::uint64_t LIMIT = API_LIMIT; inline constexpr ::std::int64_t FAR = API_FAR; @@ -2469,11 +2471,11 @@ namespace api { #include "rt.hpp" namespace api { enum class Level { - trace = 0, - debug = 1, + error = 0, + warn = 1, info = 2, - warn = 3, - error = 4, + debug = 3, + trace = 4, }; inline bool operator==(::api::Level a__, ::api::Level b_); inline bool operator!=(::api::Level a__, ::api::Level b_); diff --git a/ffi/surface/api/dart.dart b/ffi/surface/api/dart.dart index e485528f5..737fcb5c5 100644 --- a/ffi/surface/api/dart.dart +++ b/ffi/surface/api/dart.dart @@ -1003,6 +1003,8 @@ final class RankRanked extends Rank { enum Tier implements Comparable { low(0), high(1), + compareTo_(2), + partialCompareTo_(3), const Tier(this._c); String debug(); int? partialCompareTo(Tier other); @@ -1026,11 +1028,11 @@ final class ClashCandidateMatch extends ClashCandidate { const ClashCandidateMatch(this.$0); } enum Level implements Comparable { - trace(0), - debug(1), + error(0), + warn(1), info(2), - warn(3), - error(4), + debug(3), + trace(4), const Level(this._c); @override String toString(); int? partialCompareTo(Level other); diff --git a/ffi/surface/api/go.txt b/ffi/surface/api/go.txt index e374ad326..d956d3e05 100644 --- a/ffi/surface/api/go.txt +++ b/ffi/surface/api/go.txt @@ -1738,8 +1738,10 @@ func (self Ticket) GoString() string func (self Ticket) Number() uint32 type Tier int32 const ( - TierLow Tier = 0 - TierHigh Tier = 1 + TierLow Tier = 0 + TierHigh Tier = 1 + TierCompareTo Tier = 2 + TierPartialCompareTo Tier = 3 ) func (self Tier) Compare(other Tier) int func (self Tier) Equal(other Tier) bool @@ -2069,11 +2071,11 @@ package tracingcore // import "api/tracingcore" TYPES type Level int32 const ( - LevelTrace Level = 0 - LevelDebug Level = 1 + LevelError Level = 0 + LevelWarn Level = 1 LevelInfo Level = 2 - LevelWarn Level = 3 - LevelError Level = 4 + LevelDebug Level = 3 + LevelTrace Level = 4 ) func (self Level) Compare(other Level) int func (self Level) Equal(other Level) bool diff --git a/ffi/surface/api/kotlin.kt b/ffi/surface/api/kotlin.kt index 7159f9464..25a9823b9 100644 --- a/ffi/surface/api/kotlin.kt +++ b/ffi/surface/api/kotlin.kt @@ -569,7 +569,9 @@ sealed class Rank : kotlin.Comparable { } enum class Tier(internal val value: Int) { LOW(0), - HIGH(1); + HIGH(1), + COMPARE_TO(2), + PARTIAL_COMPARE_TO(3); fun debug(): kotlin.String fun partialCompareTo(other: api.Tier): kotlin.Int? companion object {} @@ -580,11 +582,11 @@ sealed class ClashCandidate { fun debug(): kotlin.String } enum class Level(internal val value: Int) { - TRACE(0), - DEBUG(1), + ERROR(0), + WARN(1), INFO(2), - WARN(3), - ERROR(4); + DEBUG(3), + TRACE(4); final override fun toString(): kotlin.String fun partialCompareTo(other: api.Level): kotlin.Int? companion object {} diff --git a/ffi/surface/api/python.pyi b/ffi/surface/api/python.pyi index d03c78735..352d7c7db 100644 --- a/ffi/surface/api/python.pyi +++ b/ffi/surface/api/python.pyi @@ -773,6 +773,8 @@ class _Rank_Ranked(Rank, _Record): class Tier(_enum.Enum): LOW = 0 HIGH = 1 + COMPARE_TO = 2 + PARTIAL_COMPARE_TO = 3 def __lt__(self, other: _object) -> _bool: ... def __le__(self, other: _object) -> _bool: ... def __gt__(self, other: _object) -> _bool: ... @@ -789,11 +791,11 @@ class _ClashCandidate_Match(ClashCandidate, _Record): def __init__(self, _0: _int) -> None: ... def __eq__(self, other: _object) -> _bool: ... class Level(_enum.Enum): - TRACE = 0 - DEBUG = 1 + ERROR = 0 + WARN = 1 INFO = 2 - WARN = 3 - ERROR = 4 + DEBUG = 3 + TRACE = 4 def __lt__(self, other: _object) -> _bool: ... def __le__(self, other: _object) -> _bool: ... def __gt__(self, other: _object) -> _bool: ... diff --git a/ffi/surface/api/swift.swift b/ffi/surface/api/swift.swift index fa122a216..129732d0f 100644 --- a/ffi/surface/api/swift.swift +++ b/ffi/surface/api/swift.swift @@ -811,6 +811,8 @@ public enum Rank: Sendable, CustomDebugStringConvertible, Equatable, Comparable public enum Tier: Sendable, CustomDebugStringConvertible, Equatable, Comparable { case low case high + case compareTo + case partialCompareTo @inlinable public var debugDescription: Swift.String { get } @inlinable public static func == (a: Tier, b: Tier) -> Swift.Bool @inlinable public static func < (a: Tier, b: Tier) -> Swift.Bool @@ -825,11 +827,11 @@ public enum ClashCandidate: Sendable, CustomDebugStringConvertible, Equatable { @inlinable public static func == (a: ClashCandidate, b: ClashCandidate) -> Swift.Bool } public enum Level: Sendable, CustomStringConvertible, Hashable, Comparable { - case trace - case debug - case info - case warn case error + case warn + case info + case debug + case trace @inlinable public var description: Swift.String { get } @inlinable public static func == (a: Level, b: Level) -> Swift.Bool @inlinable public static func < (a: Level, b: Level) -> Swift.Bool diff --git a/ffi/surface/api/web.d.ts b/ffi/surface/api/web.d.ts index bdd49f1a6..33b92d957 100644 --- a/ffi/surface/api/web.d.ts +++ b/ffi/surface/api/web.d.ts @@ -703,7 +703,7 @@ export declare function debug(self: LeftU8): string; export declare function eq(a: LeftU8, b: LeftU8): boolean; // Level.ts -export type Level = "Trace" | "Debug" | "Info" | "Warn" | "Error"; +export type Level = "Error" | "Warn" | "Info" | "Debug" | "Trace"; export declare function toString(self: Level): string; export declare function partialCmp(a: Level, b: Level): number | undefined; export declare function cmp(a: Level, b: Level): number; @@ -1479,7 +1479,7 @@ export declare function clones(): number; export { new$ as new }; // Tier.ts -export type Tier = "Low" | "High"; +export type Tier = "Low" | "High" | "CompareTo" | "PartialCompareTo"; export declare function debug(self: Tier): string; export declare function partialCmp(a: Tier, b: Tier): number | undefined; export declare function cmp(a: Tier, b: Tier): number; diff --git a/ffi/surface/moq/c.h b/ffi/surface/moq/c.h index add874d44..24578b729 100644 --- a/ffi/surface/moq/c.h +++ b/ffi/surface/moq/c.h @@ -17,7 +17,7 @@ #ifdef __cplusplus extern "C" { #endif -#define MOQ_CONTRACT ((uint64_t)0x795cd35cc0fc5623ULL) +#define MOQ_CONTRACT ((uint64_t)0x2ef7e7855318264aULL) uint64_t moq_contract(void); uint32_t moq_target(void); typedef int32_t moq_status; @@ -821,11 +821,11 @@ typedef enum moq_moq_sock_udp_EcnCodepoint { MOQ_MOQ_SOCK_UDP_ECNCODEPOINT_CE = 3, } moq_moq_sock_udp_EcnCodepoint; typedef enum moq_Level { - MOQ_LEVEL_TRACE = 0, - MOQ_LEVEL_DEBUG = 1, + MOQ_LEVEL_ERROR = 0, + MOQ_LEVEL_WARN = 1, MOQ_LEVEL_INFO = 2, - MOQ_LEVEL_WARN = 3, - MOQ_LEVEL_ERROR = 4, + MOQ_LEVEL_DEBUG = 3, + MOQ_LEVEL_TRACE = 4, } moq_Level; typedef enum moq_bound { MOQ_BOUND_UNBOUNDED = 0, diff --git a/ffi/surface/moq/cpp.hpp b/ffi/surface/moq/cpp.hpp index 1151b867f..24fc9f139 100644 --- a/ffi/surface/moq/cpp.hpp +++ b/ffi/surface/moq/cpp.hpp @@ -9866,11 +9866,11 @@ namespace std { #include "rt.hpp" namespace moq { enum class Level { - trace = 0, - debug = 1, + error = 0, + warn = 1, info = 2, - warn = 3, - error = 4, + debug = 3, + trace = 4, }; inline bool operator==(::moq::Level a, ::moq::Level b); inline bool operator!=(::moq::Level a, ::moq::Level b); diff --git a/ffi/surface/moq/dart.dart b/ffi/surface/moq/dart.dart index 27ef4c116..6ee4e6e4e 100644 --- a/ffi/surface/moq/dart.dart +++ b/ffi/surface/moq/dart.dart @@ -181,11 +181,17 @@ final class TimeOverflow implements Exception { @override bool operator ==(Object other); @override int get hashCode; } -final class Timescale { +final class Timescale implements Comparable { @override String toString(); String debug(); @override bool operator ==(Object other); @override int get hashCode; + int? partialCompareTo(Timescale other); + bool operator <(Timescale other); + bool operator <=(Timescale other); + bool operator >(Timescale other); + bool operator >=(Timescale other); + @override int compareTo(Timescale other); static Timescale get second; static Timescale get milli; static Timescale get micro; @@ -197,6 +203,11 @@ final class Timestamp { String debug(); @override bool operator ==(Object other); @override int get hashCode; + int? partialCompareTo(Timestamp other); + bool operator <(Timestamp other); + bool operator <=(Timestamp other); + bool operator >(Timestamp other); + bool operator >=(Timestamp other); static Timestamp get zero; factory Timestamp(U64 value, Timescale scale); factory Timestamp.unscaled(U64 key); @@ -217,10 +228,16 @@ final class Timestamp { Timestamp checkedAdd(Timestamp rhs); Timestamp checkedSub(Timestamp rhs); } -final class ClockInstant { +final class ClockInstant implements Comparable { String debug(); @override bool operator ==(Object other); @override int get hashCode; + int? partialCompareTo(ClockInstant other); + bool operator <(ClockInstant other); + bool operator <=(ClockInstant other); + bool operator >(ClockInstant other); + bool operator >=(ClockInstant other); + @override int compareTo(ClockInstant other); static ClockInstant get zero; factory ClockInstant.now(); RustDuration elapsed(); @@ -240,10 +257,16 @@ final class ClockElapsed implements Exception { @override bool operator ==(Object other); @override int get hashCode; } -final class ClockWall { +final class ClockWall implements Comparable { String debug(); @override bool operator ==(Object other); @override int get hashCode; + int? partialCompareTo(ClockWall other); + bool operator <(ClockWall other); + bool operator <=(ClockWall other); + bool operator >(ClockWall other); + bool operator >=(ClockWall other); + @override int compareTo(ClockWall other); static ClockWall get unixEpoch; static ClockWall get moqEpoch; factory ClockWall.now(); @@ -507,10 +530,16 @@ final class TransportLimits { U64? get receiveWindowGet; TransportLimits receiveWindowSet(U64? value); } -final class BandwidthRate { +final class BandwidthRate implements Comparable { String debug(); @override bool operator ==(Object other); @override int get hashCode; + int? partialCompareTo(BandwidthRate other); + bool operator <(BandwidthRate other); + bool operator <=(BandwidthRate other); + bool operator >(BandwidthRate other); + bool operator >=(BandwidthRate other); + @override int compareTo(BandwidthRate other); factory BandwidthRate.default_(); static BandwidthRate get zero; factory BandwidthRate.fromBps(U64 bps); @@ -535,12 +564,18 @@ final class FrameInfo { const FrameInfo({required this.size, required this.timestamp}); String debug(); } -final class GroupInfo { +final class GroupInfo implements Comparable { final U64 start; const GroupInfo({required this.start}); String debug(); @override bool operator ==(Object other); @override int get hashCode; + int? partialCompareTo(GroupInfo other); + bool operator <(GroupInfo other); + bool operator <=(GroupInfo other); + bool operator >(GroupInfo other); + bool operator >=(GroupInfo other); + @override int compareTo(GroupInfo other); } final class TrackDelay { final RustDuration? min; @@ -553,10 +588,16 @@ final class TrackDelay { TrackDelay withMin(RustDuration? min); TrackDelay withMax(RustDuration? max); } -final class TrackPosition { +final class TrackPosition implements Comparable { String debug(); @override bool operator ==(Object other); @override int get hashCode; + int? partialCompareTo(TrackPosition other); + bool operator <(TrackPosition other); + bool operator <=(TrackPosition other); + bool operator >(TrackPosition other); + bool operator >=(TrackPosition other); + @override int compareTo(TrackPosition other); factory TrackPosition.default_(); U64 get groupGet; TrackPosition groupSet(U64 value); @@ -565,28 +606,46 @@ final class TrackPosition { factory TrackPosition(U64 group, U64 frame); factory TrackPosition.group(U64 group); } -final class TrackRange { +final class TrackRange implements Comparable { final TrackAnchor start; final TrackAnchor? end; const TrackRange({required this.start, required this.end}); String debug(); @override bool operator ==(Object other); @override int get hashCode; + int? partialCompareTo(TrackRange other); + bool operator <(TrackRange other); + bool operator <=(TrackRange other); + bool operator >(TrackRange other); + bool operator >=(TrackRange other); + @override int compareTo(TrackRange other); factory TrackRange.live(); factory TrackRange.oldest(); } -final class OriginCost { +final class OriginCost implements Comparable { String debug(); @override bool operator ==(Object other); @override int get hashCode; + int? partialCompareTo(OriginCost other); + bool operator <(OriginCost other); + bool operator <=(OriginCost other); + bool operator >(OriginCost other); + bool operator >=(OriginCost other); + @override int compareTo(OriginCost other); factory OriginCost.default_(); factory OriginCost(U64 cost); U64 value(); } -final class OriginPriority { +final class OriginPriority implements Comparable { String debug(); @override bool operator ==(Object other); @override int get hashCode; + int? partialCompareTo(OriginPriority other); + bool operator <(OriginPriority other); + bool operator <=(OriginPriority other); + bool operator >(OriginPriority other); + bool operator >=(OriginPriority other); + @override int compareTo(OriginPriority other); factory OriginPriority.default_(); factory OriginPriority(int priority); int value(); @@ -1231,11 +1290,17 @@ enum TrackCompression { String debug(); factory TrackCompression.default_(); } -sealed class TrackAnchor { +sealed class TrackAnchor implements Comparable { const TrackAnchor(); String debug(); @override bool operator ==(Object other); @override int get hashCode; + int? partialCompareTo(TrackAnchor other); + bool operator <(TrackAnchor other); + bool operator <=(TrackAnchor other); + bool operator >(TrackAnchor other); + bool operator >=(TrackAnchor other); + @override int compareTo(TrackAnchor other); } final class TrackAnchorRelative extends TrackAnchor { final U64 $0; @@ -2032,14 +2097,20 @@ enum MoqSockUdpEcnCodepoint { String debug(); static MoqSockUdpEcnCodepoint? fromBits(int x); } -enum Level { - trace(0), - debug(1), +enum Level implements Comparable { + error(0), + warn(1), info(2), - warn(3), - error(4), + debug(3), + trace(4), const Level(this._c); @override String toString(); + int? partialCompareTo(Level other); + bool operator <(Level other); + bool operator <=(Level other); + bool operator >(Level other); + bool operator >=(Level other); + @override int compareTo(Level other); } final class Park extends _Object { String debug(); @@ -2076,22 +2147,34 @@ final class Driver extends _Object { String debug(); ClockInstant? poll(ClockInstant now, Waiter waiter); } -final class Instance extends _Object { +final class Instance extends _Object implements Comparable { @override String toString(); String debug(); Instance clone(); @override bool operator ==(Object other); @override int get hashCode; + int? partialCompareTo(Instance other); + bool operator <(Instance other); + bool operator <=(Instance other); + bool operator >(Instance other); + bool operator >=(Instance other); + @override int compareTo(Instance other); factory Instance.random(); String asStr(); bool isMinted(); } -final class Path extends _Object { +final class Path extends _Object implements Comparable { @override String toString(); String debug(); Path clone(); @override bool operator ==(Object other); @override int get hashCode; + int? partialCompareTo(Path other); + bool operator <(Path other); + bool operator <=(Path other); + bool operator >(Path other); + bool operator >=(Path other); + @override int compareTo(Path other); factory Path.default_(); factory Path(String s); factory Path.fromStatic(String s); @@ -2107,12 +2190,18 @@ final class Path extends _Object { Path? tryResolve(PathRelative rel); PathRelative? relative(Path base); } -final class Pattern extends _Object { +final class Pattern extends _Object implements Comparable { @override String toString(); String debug(); Pattern clone(); @override bool operator ==(Object other); @override int get hashCode; + int? partialCompareTo(Pattern other); + bool operator <(Pattern other); + bool operator <=(Pattern other); + bool operator >(Pattern other); + bool operator >=(Pattern other); + @override int compareTo(Pattern other); factory Pattern.default_(); factory Pattern(List segments); factory Pattern.all(); @@ -2246,11 +2335,17 @@ final class Versions extends _Object { bool contains(Version version); List iter(); } -final class Specificity extends _Object { +final class Specificity extends _Object implements Comparable { String debug(); Specificity clone(); @override bool operator ==(Object other); @override int get hashCode; + int? partialCompareTo(Specificity other); + bool operator <(Specificity other); + bool operator <=(Specificity other); + bool operator >(Specificity other); + bool operator >=(Specificity other); + @override int compareTo(Specificity other); } final class ClockClock extends _Object { String debug(); @@ -2493,12 +2588,18 @@ final class MuxError extends _Object implements Exception { String debug(); MuxError clone(); } -final class TokioDuration extends _Object { +final class TokioDuration extends _Object implements Comparable { @override String toString(); String debug(); TokioDuration clone(); @override bool operator ==(Object other); @override int get hashCode; + int? partialCompareTo(TokioDuration other); + bool operator <(TokioDuration other); + bool operator <=(TokioDuration other); + bool operator >(TokioDuration other); + bool operator >=(TokioDuration other); + @override int compareTo(TokioDuration other); factory TokioDuration.default_(); } final class TokioBackoff extends _Object { @@ -7651,23 +7752,35 @@ final class MoqTokioQuicDemuxDatagram extends _Object { final class MoqSockDemuxPin extends _Object { String debug(); } -final class Url extends _Object { +final class Url extends _Object implements Comparable { @override String toString(); String debug(); Url clone(); @override bool operator ==(Object other); @override int get hashCode; + int? partialCompareTo(Url other); + bool operator <(Url other); + bool operator <=(Url other); + bool operator >(Url other); + bool operator >=(Url other); + @override int compareTo(Url other); factory Url.parse(String input); } final class Json extends _Object { factory Json.parse(String input); String toText(); } -final class Instant extends _Object { +final class Instant extends _Object implements Comparable { String debug(); Instant clone(); @override bool operator ==(Object other); @override int get hashCode; + int? partialCompareTo(Instant other); + bool operator <(Instant other); + bool operator <=(Instant other); + bool operator >(Instant other); + bool operator >=(Instant other); + @override int compareTo(Instant other); } final class RustlsServerConfig extends _Object { RustlsServerConfig clone(); diff --git a/ffi/surface/moq/go.txt b/ffi/surface/moq/go.txt index 3ec5ed465..a50eb4b9c 100644 --- a/ffi/surface/moq/go.txt +++ b/ffi/surface/moq/go.txt @@ -8983,11 +8983,11 @@ package tracingcore // import "moq/tracingcore" TYPES type Level int32 const ( - LevelTrace Level = 0 - LevelDebug Level = 1 + LevelError Level = 0 + LevelWarn Level = 1 LevelInfo Level = 2 - LevelWarn Level = 3 - LevelError Level = 4 + LevelDebug Level = 3 + LevelTrace Level = 4 ) func (self Level) Compare(other Level) int func (self Level) Equal(other Level) bool diff --git a/ffi/surface/moq/kotlin.kt b/ffi/surface/moq/kotlin.kt index e2ccb7466..332e3ce37 100644 --- a/ffi/surface/moq/kotlin.kt +++ b/ffi/surface/moq/kotlin.kt @@ -1433,11 +1433,11 @@ enum class MoqSockUdpEcnCodepoint(internal val value: Int) { } } enum class Level(internal val value: Int) { - TRACE(0), - DEBUG(1), + ERROR(0), + WARN(1), INFO(2), - WARN(3), - ERROR(4); + DEBUG(3), + TRACE(4); final override fun toString(): kotlin.String fun partialCompareTo(other: moq.Level): kotlin.Int? companion object {} diff --git a/ffi/surface/moq/python.pyi b/ffi/surface/moq/python.pyi index 52d255e74..bfcadf279 100644 --- a/ffi/surface/moq/python.pyi +++ b/ffi/surface/moq/python.pyi @@ -1873,11 +1873,11 @@ class MoqSockUdpEcnCodepoint(_enum.Enum): @_staticmethod def from_bits(x: _int) -> MoqSockUdpEcnCodepoint | None: ... class Level(_enum.Enum): - TRACE = 0 - DEBUG = 1 + ERROR = 0 + WARN = 1 INFO = 2 - WARN = 3 - ERROR = 4 + DEBUG = 3 + TRACE = 4 def __lt__(self, other: _object) -> _bool: ... def __le__(self, other: _object) -> _bool: ... def __gt__(self, other: _object) -> _bool: ... diff --git a/ffi/surface/moq/swift.swift b/ffi/surface/moq/swift.swift index a31f53cfe..294347be9 100644 --- a/ffi/surface/moq/swift.swift +++ b/ffi/surface/moq/swift.swift @@ -1679,11 +1679,11 @@ public enum MoqSockUdpEcnCodepoint: Sendable, CustomDebugStringConvertible, Equa @inlinable public static func fromBits(_ x: Swift.UInt8) -> MoqSockUdpEcnCodepoint? } public enum Level: Sendable, CustomStringConvertible, Hashable, Comparable { - case trace - case debug - case info - case warn case error + case warn + case info + case debug + case trace @inlinable public var description: Swift.String { get } @inlinable public static func == (a: Level, b: Level) -> Swift.Bool @inlinable public static func < (a: Level, b: Level) -> Swift.Bool From 9665ab2bee6c418c921d7bf6dda809b9578da39f Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Fri, 20 Nov 2026 02:29:25 -0800 Subject: [PATCH 8/9] fix(ffi): define C++20's <=> in the namespace, so no class differs between standards Co-Authored-By: Claude Opus 5.5 --- ffi/src/cpp.rs | 25 +++++++++----- ffi/surface/api/cpp.hpp | 27 +++++++--------- ffi/surface/moq/cpp.hpp | 72 ++++++++++++----------------------------- 3 files changed, 50 insertions(+), 74 deletions(-) diff --git a/ffi/src/cpp.rs b/ffi/src/cpp.rs index 41863fcc1..1673999c7 100644 --- a/ffi/src/cpp.rs +++ b/ffi/src/cpp.rs @@ -1060,15 +1060,20 @@ impl<'a> Header<'a> { let ops = self.orders(t.ord, &format!("const {name} &{a}, const {name} &{b}"), &|suffix| { ( String::new(), - format!("::{c}_{suffix}({a}.raw_.get(), {b}.raw_.get(){status})"), + format!("::{c}_{suffix}({d}::access::raw({a}), {d}::access::raw({b}){status})"), ) }); + // Friends, as `==` is, but for C++20's `<=>`: a class that differs between + // standards breaks the one-definition rule, so it lives in the namespace. for op in ops { - body.push(op.guarded(format!( - "\tfriend {} {{\n\t{}\n\t}}", - op.head, - op.body.trim_end().replace('\n', "\n\t") - ))); + match op.cpp20 { + true => self.def(format!("{}\n", op.define("inline "))), + false => body.push(format!( + "\tfriend {} {{\n\t{}\n\t}}", + op.head, + op.body.trim_end().replace('\n', "\n\t") + )), + } } } if t.hash { @@ -1327,9 +1332,13 @@ impl<'a> Header<'a> { format!("::{c}_{suffix}(&c_a_, &c_b_{status})"), ) }); - // Declared friends, as `==` is, and defined after the class. + // Declared friends, as `==` is, and defined after the class, but for C++20's + // `<=>`: a class that differs between standards breaks the one-definition + // rule, so it is the namespace's alone. for op in ops { - body.push(op.guarded(format!("\tfriend {};", op.head))); + if !op.cpp20 { + body.push(format!("\tfriend {};", op.head)); + } self.def(format!("{}\n", op.define("inline "))); } } diff --git a/ffi/surface/api/cpp.hpp b/ffi/surface/api/cpp.hpp index a1a8fd9bb..7cd603034 100644 --- a/ffi/surface/api/cpp.hpp +++ b/ffi/surface/api/cpp.hpp @@ -589,9 +589,6 @@ namespace api { friend bool operator<=(const Quantity &a__, const Quantity &b_); friend bool operator>(const Quantity &a__, const Quantity &b_); friend bool operator>=(const Quantity &a__, const Quantity &b_); - #if defined(__cpp_lib_three_way_comparison) - friend ::std::partial_ordering operator<=>(const Quantity &a__, const Quantity &b_); - #endif RUST2_FFI_CALLABLE ::api::buf debug() const; static ::api::Quantity new_(::std::int64_t value, char32_t unit); }; @@ -604,9 +601,6 @@ namespace api { friend bool operator<=(const Pass &a__, const Pass &b_); friend bool operator>(const Pass &a__, const Pass &b_); friend bool operator>=(const Pass &a__, const Pass &b_); - #if defined(__cpp_lib_three_way_comparison) - friend ::std::weak_ordering operator<=>(const Pass &a__, const Pass &b_); - #endif RUST2_FFI_CALLABLE ::api::buf debug() const; static ::api::Pass new_(::std::uint32_t number); RUST2_FFI_CONSUMES ::std::uint32_t redeem() &&; @@ -1138,9 +1132,6 @@ namespace api { friend bool operator<=(const Version &a__, const Version &b_); friend bool operator>(const Version &a__, const Version &b_); friend bool operator>=(const Version &a__, const Version &b_); - #if defined(__cpp_lib_three_way_comparison) - friend ::std::weak_ordering operator<=>(const Version &a__, const Version &b_); - #endif ::api::buf debug() const; }; struct Spot { @@ -1349,6 +1340,12 @@ namespace api { struct clash_Candidate_Match { ::std::uint8_t _0; }; + #if defined(__cpp_lib_three_way_comparison) + inline ::std::partial_ordering operator<=>(const Quantity &a__, const Quantity &b_); + #endif + #if defined(__cpp_lib_three_way_comparison) + inline ::std::weak_ordering operator<=>(const Pass &a__, const Pass &b_); + #endif inline bool operator==(const Stamp &a__, const Stamp &b_); inline bool operator==(const Point &a__, const Point &b_); inline bool operator==(const Label &a__, const Label &b_); @@ -2386,12 +2383,12 @@ namespace api { friend bool operator<=(const Instant &a__, const Instant &b_); friend bool operator>(const Instant &a__, const Instant &b_); friend bool operator>=(const Instant &a__, const Instant &b_); - #if defined(__cpp_lib_three_way_comparison) - friend ::std::weak_ordering operator<=>(const Instant &a__, const Instant &b_); - #endif RUST2_FFI_CALLABLE ::std::uint64_t hash() const; RUST2_FFI_CALLABLE ::api::buf debug() const; }; + #if defined(__cpp_lib_three_way_comparison) + inline ::std::weak_ordering operator<=>(const Instant &a__, const Instant &b_); + #endif } namespace std { template <> struct hash<::api::Instant> { @@ -2518,14 +2515,14 @@ namespace api { friend bool operator<=(const Url &a__, const Url &b_); friend bool operator>(const Url &a__, const Url &b_); friend bool operator>=(const Url &a__, const Url &b_); - #if defined(__cpp_lib_three_way_comparison) - friend ::std::weak_ordering operator<=>(const Url &a__, const Url &b_); - #endif RUST2_FFI_CALLABLE ::std::uint64_t hash() const; RUST2_FFI_CALLABLE ::api::buf to_string() const; RUST2_FFI_CALLABLE ::api::buf debug() const; static ::api::result<::api::Url, ::api::buf> parse(::api::input input_); }; + #if defined(__cpp_lib_three_way_comparison) + inline ::std::weak_ordering operator<=>(const Url &a__, const Url &b_); + #endif } namespace std { template <> struct hash<::api::Url> { diff --git a/ffi/surface/moq/cpp.hpp b/ffi/surface/moq/cpp.hpp index 24fc9f139..b985a8578 100644 --- a/ffi/surface/moq/cpp.hpp +++ b/ffi/surface/moq/cpp.hpp @@ -1002,9 +1002,6 @@ namespace moq { friend bool operator<=(const clock_Instant &a, const clock_Instant &b); friend bool operator>(const clock_Instant &a, const clock_Instant &b); friend bool operator>=(const clock_Instant &a, const clock_Instant &b); - #if defined(__cpp_lib_three_way_comparison) - friend ::std::weak_ordering operator<=>(const clock_Instant &a, const clock_Instant &b); - #endif ::moq::buf debug() const; static ::moq::clock_Instant ZERO(); static ::moq::clock_Instant now(); @@ -1032,9 +1029,6 @@ namespace moq { friend bool operator<=(const clock_Wall &a, const clock_Wall &b); friend bool operator>(const clock_Wall &a, const clock_Wall &b); friend bool operator>=(const clock_Wall &a, const clock_Wall &b); - #if defined(__cpp_lib_three_way_comparison) - friend ::std::weak_ordering operator<=>(const clock_Wall &a, const clock_Wall &b); - #endif ::moq::buf debug() const; static ::moq::clock_Wall UNIX_EPOCH(); static ::moq::clock_Wall MOQ_EPOCH(); @@ -5228,9 +5222,6 @@ namespace moq { friend bool operator<=(const Instance &a, const Instance &b); friend bool operator>(const Instance &a, const Instance &b); friend bool operator>=(const Instance &a, const Instance &b); - #if defined(__cpp_lib_three_way_comparison) - friend ::std::weak_ordering operator<=>(const Instance &a, const Instance &b); - #endif RUST2_FFI_CALLABLE ::std::uint64_t hash() const; RUST2_FFI_CALLABLE ::moq::buf to_string() const; RUST2_FFI_CALLABLE ::moq::buf debug() const; @@ -5249,9 +5240,6 @@ namespace moq { friend bool operator<=(const Path &a, const Path &b); friend bool operator>(const Path &a, const Path &b); friend bool operator>=(const Path &a, const Path &b); - #if defined(__cpp_lib_three_way_comparison) - friend ::std::weak_ordering operator<=>(const Path &a, const Path &b); - #endif RUST2_FFI_CALLABLE ::std::uint64_t hash() const; RUST2_FFI_CALLABLE ::moq::buf to_string() const; RUST2_FFI_CALLABLE ::moq::buf debug() const; @@ -6593,9 +6581,6 @@ namespace moq { friend bool operator<=(const Timescale &a, const Timescale &b); friend bool operator>(const Timescale &a, const Timescale &b); friend bool operator>=(const Timescale &a, const Timescale &b); - #if defined(__cpp_lib_three_way_comparison) - friend ::std::weak_ordering operator<=>(const Timescale &a, const Timescale &b); - #endif ::moq::buf to_string() const; ::moq::buf debug() const; static ::moq::Timescale SECOND(); @@ -6612,9 +6597,6 @@ namespace moq { friend bool operator<=(const Timestamp &a, const Timestamp &b); friend bool operator>(const Timestamp &a, const Timestamp &b); friend bool operator>=(const Timestamp &a, const Timestamp &b); - #if defined(__cpp_lib_three_way_comparison) - friend ::std::partial_ordering operator<=>(const Timestamp &a, const Timestamp &b); - #endif ::moq::buf debug() const; static ::moq::Timestamp ZERO(); static ::moq::result<::moq::Timestamp, ::moq::TimeOverflow> new_(::std::uint64_t value, const ::moq::Timescale &scale); @@ -6896,9 +6878,6 @@ namespace moq { friend bool operator<=(const bandwidth_Rate &a, const bandwidth_Rate &b); friend bool operator>(const bandwidth_Rate &a, const bandwidth_Rate &b); friend bool operator>=(const bandwidth_Rate &a, const bandwidth_Rate &b); - #if defined(__cpp_lib_three_way_comparison) - friend ::std::weak_ordering operator<=>(const bandwidth_Rate &a, const bandwidth_Rate &b); - #endif ::moq::buf debug() const; static bandwidth_Rate default_(); static ::moq::bandwidth_Rate ZERO(); @@ -6930,9 +6909,6 @@ namespace moq { friend bool operator<=(const group_Info &a, const group_Info &b); friend bool operator>(const group_Info &a, const group_Info &b); friend bool operator>=(const group_Info &a, const group_Info &b); - #if defined(__cpp_lib_three_way_comparison) - friend ::std::weak_ordering operator<=>(const group_Info &a, const group_Info &b); - #endif ::moq::buf debug() const; }; struct track_Delay { @@ -6952,9 +6928,6 @@ namespace moq { friend bool operator<=(const track_Position &a, const track_Position &b); friend bool operator>(const track_Position &a, const track_Position &b); friend bool operator>=(const track_Position &a, const track_Position &b); - #if defined(__cpp_lib_three_way_comparison) - friend ::std::weak_ordering operator<=>(const track_Position &a, const track_Position &b); - #endif ::moq::buf debug() const; static track_Position default_(); ::std::uint64_t group_get() const; @@ -6981,9 +6954,6 @@ namespace moq { friend bool operator<=(const track_Range &a, const track_Range &b); friend bool operator>(const track_Range &a, const track_Range &b); friend bool operator>=(const track_Range &a, const track_Range &b); - #if defined(__cpp_lib_three_way_comparison) - friend ::std::weak_ordering operator<=>(const track_Range &a, const track_Range &b); - #endif ::moq::buf debug() const; static ::moq::track_Range live(); static ::moq::track_Range oldest(); @@ -6995,9 +6965,6 @@ namespace moq { friend bool operator<=(const origin_Cost &a, const origin_Cost &b); friend bool operator>(const origin_Cost &a, const origin_Cost &b); friend bool operator>=(const origin_Cost &a, const origin_Cost &b); - #if defined(__cpp_lib_three_way_comparison) - friend ::std::weak_ordering operator<=>(const origin_Cost &a, const origin_Cost &b); - #endif ::moq::buf debug() const; static origin_Cost default_(); static ::moq::origin_Cost new_(::std::uint64_t cost); @@ -7010,9 +6977,6 @@ namespace moq { friend bool operator<=(const origin_Priority &a, const origin_Priority &b); friend bool operator>(const origin_Priority &a, const origin_Priority &b); friend bool operator>=(const origin_Priority &a, const origin_Priority &b); - #if defined(__cpp_lib_three_way_comparison) - friend ::std::weak_ordering operator<=>(const origin_Priority &a, const origin_Priority &b); - #endif ::moq::buf debug() const; static origin_Priority default_(); static ::moq::origin_Priority new_(::std::int8_t priority); @@ -7104,6 +7068,12 @@ namespace moq { }; struct transport_memory_Error_Closed { }; + #if defined(__cpp_lib_three_way_comparison) + inline ::std::weak_ordering operator<=>(const Instance &a, const Instance &b); + #endif + #if defined(__cpp_lib_three_way_comparison) + inline ::std::weak_ordering operator<=>(const Path &a, const Path &b); + #endif inline bool operator==(const TimeOverflow &a, const TimeOverflow &b); inline bool operator==(const Timescale &a, const Timescale &b); inline bool operator<(const Timescale &a, const Timescale &b); @@ -7367,9 +7337,6 @@ namespace moq { friend bool operator<=(const Pattern &a, const Pattern &b); friend bool operator>(const Pattern &a, const Pattern &b); friend bool operator>=(const Pattern &a, const Pattern &b); - #if defined(__cpp_lib_three_way_comparison) - friend ::std::weak_ordering operator<=>(const Pattern &a, const Pattern &b); - #endif RUST2_FFI_CALLABLE ::std::uint64_t hash() const; RUST2_FFI_CALLABLE ::moq::buf to_string() const; RUST2_FFI_CALLABLE ::moq::buf debug() const; @@ -7426,9 +7393,6 @@ namespace moq { friend bool operator<=(const Specificity &a, const Specificity &b); friend bool operator>(const Specificity &a, const Specificity &b); friend bool operator>=(const Specificity &a, const Specificity &b); - #if defined(__cpp_lib_three_way_comparison) - friend ::std::weak_ordering operator<=>(const Specificity &a, const Specificity &b); - #endif RUST2_FFI_CALLABLE ::std::uint64_t hash() const; RUST2_FFI_CALLABLE ::moq::buf debug() const; }; @@ -7452,6 +7416,12 @@ namespace moq { }; struct Segment_Globstar { }; + #if defined(__cpp_lib_three_way_comparison) + inline ::std::weak_ordering operator<=>(const Pattern &a, const Pattern &b); + #endif + #if defined(__cpp_lib_three_way_comparison) + inline ::std::weak_ordering operator<=>(const Specificity &a, const Specificity &b); + #endif inline bool operator==(const ::moq::InvalidPattern &a, const ::moq::InvalidPattern &b); inline bool operator!=(const ::moq::InvalidPattern &a, const ::moq::InvalidPattern &b); inline ::moq::buf InvalidPattern_to_string(const ::moq::InvalidPattern &self); @@ -8975,12 +8945,12 @@ namespace moq { friend bool operator<=(const Instant &a, const Instant &b); friend bool operator>(const Instant &a, const Instant &b); friend bool operator>=(const Instant &a, const Instant &b); - #if defined(__cpp_lib_three_way_comparison) - friend ::std::weak_ordering operator<=>(const Instant &a, const Instant &b); - #endif RUST2_FFI_CALLABLE ::std::uint64_t hash() const; RUST2_FFI_CALLABLE ::moq::buf debug() const; }; + #if defined(__cpp_lib_three_way_comparison) + inline ::std::weak_ordering operator<=>(const Instant &a, const Instant &b); + #endif } namespace std { template <> struct hash<::moq::Instant> { @@ -9046,9 +9016,6 @@ namespace moq { friend bool operator<=(const tokio_Duration &a, const tokio_Duration &b); friend bool operator>(const tokio_Duration &a, const tokio_Duration &b); friend bool operator>=(const tokio_Duration &a, const tokio_Duration &b); - #if defined(__cpp_lib_three_way_comparison) - friend ::std::weak_ordering operator<=>(const tokio_Duration &a, const tokio_Duration &b); - #endif RUST2_FFI_CALLABLE ::std::uint64_t hash() const; RUST2_FFI_CALLABLE ::moq::buf to_string() const; RUST2_FFI_CALLABLE ::moq::buf debug() const; @@ -9804,6 +9771,9 @@ namespace moq { }; struct moq_tokio_connect_Error_MissingHost { }; + #if defined(__cpp_lib_three_way_comparison) + inline ::std::weak_ordering operator<=>(const tokio_Duration &a, const tokio_Duration &b); + #endif inline bool operator==(::moq::tokio_ConnectError a, ::moq::tokio_ConnectError b); inline bool operator!=(::moq::tokio_ConnectError a, ::moq::tokio_ConnectError b); inline ::moq::buf tokio_ConnectError_to_string(::moq::tokio_ConnectError self); @@ -9901,14 +9871,14 @@ namespace moq { friend bool operator<=(const Url &a, const Url &b); friend bool operator>(const Url &a, const Url &b); friend bool operator>=(const Url &a, const Url &b); - #if defined(__cpp_lib_three_way_comparison) - friend ::std::weak_ordering operator<=>(const Url &a, const Url &b); - #endif RUST2_FFI_CALLABLE ::std::uint64_t hash() const; RUST2_FFI_CALLABLE ::moq::buf to_string() const; RUST2_FFI_CALLABLE ::moq::buf debug() const; static ::moq::result<::moq::Url, ::moq::buf> parse(::moq::input input_); }; + #if defined(__cpp_lib_three_way_comparison) + inline ::std::weak_ordering operator<=>(const Url &a, const Url &b); + #endif } namespace std { template <> struct hash<::moq::Url> { From 0d332ba4bf8165add450d350100358e984ff5333 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Fri, 20 Nov 2026 02:36:24 -0800 Subject: [PATCH 9/9] ffi: regenerate surface after merging #904 Co-Authored-By: Claude Opus 5.5 --- ffi/surface/api/c.h | 71 +++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 66 insertions(+), 5 deletions(-) diff --git a/ffi/surface/api/c.h b/ffi/surface/api/c.h index 45ecf4df1..a66f87274 100644 --- a/ffi/surface/api/c.h +++ b/ffi/surface/api/c.h @@ -17,7 +17,7 @@ #ifdef __cplusplus extern "C" { #endif -#define API_CONTRACT ((uint64_t)0x4e27077ce3222e8fULL) +#define API_CONTRACT ((uint64_t)0xec916b9d58c97fe1ULL) uint64_t api_contract(void); uint32_t api_target(void); typedef int32_t api_status; @@ -159,6 +159,8 @@ typedef struct api_Stack api_Stack; typedef struct api_Refusal api_Refusal; typedef struct api_Fault api_Fault; typedef struct api_c api_c; +typedef struct api_Quantity api_Quantity; +typedef struct api_Pass api_Pass; typedef struct api_Key api_Key; typedef struct api_clash_Seed api_clash_Seed; typedef struct api_clash_Empty_string api_clash_Empty_string; @@ -193,12 +195,18 @@ typedef enum api_Family { typedef enum api_VecClashTone { API_VECCLASHTONE_ERROR = 0, } api_VecClashTone; +typedef enum api_Tier { + API_TIER_LOW = 0, + API_TIER_HIGH = 1, + API_TIER_COMPARE_TO = 2, + API_TIER_PARTIAL_COMPARE_TO = 3, +} api_Tier; typedef enum api_Level { - API_LEVEL_TRACE = 0, - API_LEVEL_DEBUG = 1, + API_LEVEL_ERROR = 0, + API_LEVEL_WARN = 1, API_LEVEL_INFO = 2, - API_LEVEL_WARN = 3, - API_LEVEL_ERROR = 4, + API_LEVEL_DEBUG = 3, + API_LEVEL_TRACE = 4, } api_Level; typedef enum api_bound { API_BOUND_UNBOUNDED = 0, @@ -828,6 +836,10 @@ typedef struct api_Qualifiers { double api; double kotlin; } api_Qualifiers; +typedef struct api_Version { + uint16_t major; + uint16_t minor; +} api_Version; typedef struct api_Spot { uint32_t x; uint32_t y; @@ -1081,6 +1093,22 @@ typedef struct api_Builtin { api_Builtin_Native native; }; } api_Builtin; +typedef enum api_Rank_tag { + API_RANK_UNRANKED = 0, + API_RANK_RANKED = 1, +} api_Rank_tag; +typedef struct api_Rank_Ranked { + uint8_t compare; + uint8_t partial_compare; + uint8_t compare_to; + uint8_t partial_compare_to; +} api_Rank_Ranked; +typedef struct api_Rank { + api_Rank_tag tag; + union { + api_Rank_Ranked ranked; + }; +} api_Rank; typedef enum api_clash_Candidate_tag { API_CLASH_CANDIDATE_NONE = 0, API_CLASH_CANDIDATE_MATCH = 1, @@ -1342,6 +1370,11 @@ bool api_a_eq(const api_a *a, const api_a *b); API_MUST_USE api_buf api_a_debug(const api_a *self); void api_Qualifiers_free(api_Qualifiers *self); bool api_Qualifiers_eq(const api_Qualifiers *a, const api_Qualifiers *b); +void api_Version_free(api_Version *self); +bool api_Version_eq(const api_Version *a, const api_Version *b); +int8_t api_Version_partial_cmp(const api_Version *a, const api_Version *b); +int8_t api_Version_cmp(const api_Version *a, const api_Version *b); +API_MUST_USE api_buf api_Version_debug(const api_Version *self); void api_Spot_free(api_Spot *self); bool api_Spot_eq(const api_Spot *a, const api_Spot *b); API_MUST_USE api_buf api_Spot_debug(const api_Spot *self); @@ -1448,11 +1481,22 @@ bool api_b_eq(const api_b *a, const api_b *b); API_MUST_USE api_buf api_b_debug(const api_b *self); void api_Builtin_free(api_Builtin *self); bool api_Builtin_eq(const api_Builtin *a, const api_Builtin *b); +void api_Rank_free(api_Rank *self); +bool api_Rank_eq(const api_Rank *a, const api_Rank *b); +int8_t api_Rank_partial_cmp(const api_Rank *a, const api_Rank *b); +int8_t api_Rank_cmp(const api_Rank *a, const api_Rank *b); +API_MUST_USE api_buf api_Rank_debug(const api_Rank *self); +bool api_Tier_eq(const api_Tier *a, const api_Tier *b); +int8_t api_Tier_partial_cmp(const api_Tier *a, const api_Tier *b); +int8_t api_Tier_cmp(const api_Tier *a, const api_Tier *b); +API_MUST_USE api_buf api_Tier_debug(const api_Tier *self); void api_clash_Candidate_free(api_clash_Candidate *self); bool api_clash_Candidate_eq(const api_clash_Candidate *a, const api_clash_Candidate *b); API_MUST_USE api_buf api_clash_Candidate_debug(const api_clash_Candidate *self); bool api_Level_eq(const api_Level *a, const api_Level *b); uint64_t api_Level_hash(const api_Level *self); +int8_t api_Level_partial_cmp(const api_Level *a, const api_Level *b); +int8_t api_Level_cmp(const api_Level *a, const api_Level *b); API_MUST_USE api_buf api_Level_to_string(const api_Level *self); void api_Board_free(api_Board *self); void api_Board_drop(api_Board *self, api_status *status); @@ -1967,6 +2011,19 @@ void api_c_free(api_c *self); bool api_c_eq(const api_c *a, const api_c *b); API_MUST_USE api_buf api_c_debug(const api_c *self); API_MUST_USE api_c *api_c_new(uint8_t value); +void api_Quantity_free(api_Quantity *self); +bool api_Quantity_eq(const api_Quantity *a, const api_Quantity *b); +int8_t api_Quantity_partial_cmp(const api_Quantity *a, const api_Quantity *b); +API_MUST_USE api_buf api_Quantity_debug(const api_Quantity *self); +API_MUST_USE api_Quantity *api_Quantity_new(int64_t value, uint32_t unit); +void api_Pass_free(api_Pass *self); +void api_Pass_drop(api_Pass *self, api_status *status); +bool api_Pass_eq(const api_Pass *a, const api_Pass *b, api_status *status); +int8_t api_Pass_partial_cmp(const api_Pass *a, const api_Pass *b, api_status *status); +int8_t api_Pass_cmp(const api_Pass *a, const api_Pass *b, api_status *status); +API_MUST_USE api_buf api_Pass_debug(const api_Pass *self, api_status *status); +API_MUST_USE api_Pass *api_Pass_new(uint32_t number); +uint32_t api_Pass_redeem(api_Pass *self, api_status *status); void api_Key_free(api_Key *self); bool api_Key_borrowed(const api_Key *self); API_MUST_USE api_Key *api_Key_clone(const api_Key *self); @@ -1995,6 +2052,8 @@ bool api_Url_borrowed(const api_Url *self); API_MUST_USE api_Url *api_Url_clone(const api_Url *self, api_status *status); bool api_Url_eq(const api_Url *a, const api_Url *b, api_status *status); uint64_t api_Url_hash(const api_Url *self, api_status *status); +int8_t api_Url_partial_cmp(const api_Url *a, const api_Url *b, api_status *status); +int8_t api_Url_cmp(const api_Url *a, const api_Url *b, api_status *status); API_MUST_USE api_buf api_Url_to_string(const api_Url *self, api_status *status); API_MUST_USE api_buf api_Url_debug(const api_Url *self, api_status *status); API_MUST_USE bool api_Url_parse(api_buf input, api_Url **out, api_buf *err); @@ -2007,6 +2066,8 @@ bool api_Instant_borrowed(const api_Instant *self); API_MUST_USE api_Instant *api_Instant_clone(const api_Instant *self); bool api_Instant_eq(const api_Instant *a, const api_Instant *b); uint64_t api_Instant_hash(const api_Instant *self); +int8_t api_Instant_partial_cmp(const api_Instant *a, const api_Instant *b); +int8_t api_Instant_cmp(const api_Instant *a, const api_Instant *b); API_MUST_USE api_buf api_Instant_debug(const api_Instant *self); void api_std_io_Error_free(api_std_io_Error *self); void api_std_io_Error_drop(api_std_io_Error *self, api_status *status);