diff --git a/ffi/README.md b/ffi/README.md index e532cccb4..4dfc50fc7 100644 --- a/ffi/README.md +++ b/ffi/README.md @@ -511,9 +511,11 @@ packages place it in. - **Names** are the C names without the prefix, in a namespace of it: `moq_track_Producer` is `moq::track_Producer`, and its method `moq_track_Producer_append_group` is - `moq::track_Producer::append_group`. A keyword, or a macro GNU dialects predefine - (`unix`, `linux`, `i386`, as in moq-tokio's `tokio::unix_`, and each of them followed by - underscores, so `unix_` becomes `unix__`), takes a trailing `_` (`counter::new_`), + `moq::track_Producer::append_group`. A keyword, or a macro of a short list that GNU dialects predefine or the + C library's headers define (`unix`, `linux`, `i386`, as in moq-tokio's `tokio::unix_`, + and `errno`, `assert`, `offsetof`, `stdin`, `stdout`, and `stderr`, and each of them + followed by underscores, so `unix_` becomes `unix__`; any other macro, such as `EOF` or + `va_start`, is not escaped yet, see [ffi-apart](../quest/m1/ffi-apart.md)), takes a trailing `_` (`counter::new_`), as does a member named as its class, one of its fields, or a member a trait gives it, and a parameter named as a member or as anything in the namespace, which it would hide. A name the escape leaves alone keeps it, and one escaped onto another's takes more `_`s diff --git a/ffi/fixtures/api/src/lib.rs b/ffi/fixtures/api/src/lib.rs index c8b88f9b0..5375942c6 100644 --- a/ffi/fixtures/api/src/lib.rs +++ b/ffi/fixtures/api/src/lib.rs @@ -4794,6 +4794,44 @@ pub struct DoubleArray { pub len: u32, } +/// The value of `errno`, a macro `` defines: a C++ function of this name must not +/// be rewritten as `(*__errno_location ())`. +pub fn errno() -> i32 { + 7 +} + +/// A function named as `assert`, which `` defines as a macro. +pub fn assert(holds: bool) -> bool { + holds +} + +/// A function named as `offsetof`, which `` defines as a macro. +pub fn offsetof(field: u8) -> u8 { + field +} + +/// A record of fields named as macros a C library's headers define, which each binding +/// keeps apart. +pub mod macros { + /// A record of fields named as `stdin`, `stdout`, and `stderr`, macros on some C libraries. + #[derive(Clone, Copy, Debug, PartialEq)] + pub struct Streams { + pub stdin: u8, + pub stdout: u8, + pub stderr: u8, + pub errno: u8, + } + + /// The sum of `streams`' fields, and `errno`, a parameter named as the macro. + pub fn streamed(streams: Streams, errno: u8) -> u32 { + u32::from(streams.stdin) + + u32::from(streams.stdout) + + u32::from(streams.stderr) + + u32::from(streams.errno) + + u32::from(errno) + } +} + pub mod clash { /// A pitch in hertz, whose name Pascal case cannot tell from `TONE`'s. #[derive(Clone, Copy, Debug, PartialEq)] diff --git a/ffi/src/abi.rs b/ffi/src/abi.rs index 1354181b0..907c98688 100644 --- a/ffi/src/abi.rs +++ b/ffi/src/abi.rs @@ -2044,6 +2044,14 @@ pub(crate) fn distinct(names: impl IntoIterator) -> Vec { .collect() } +/// Lowercase macros that would rewrite a name of the same spelling in a program including +/// the header: those GNU dialects predefine, as CMake's default `-std=gnu11` and +/// `-std=gnu++17` do, and those of the C library's headers, which C++'s own and a C +/// program's, such as ``, include. +pub(crate) const MACROS: &[&str] = &[ + "assert", "errno", "i386", "linux", "offsetof", "stderr", "stdin", "stdout", "unix", +]; + /// A name that C or C++, which includes the header, would read as a keyword with `_` /// appended, and one starting with a digit with `_` prepended. Appended, since MSVC reads /// `_inline`, `_asm`, and `_try` as keywords too; a name already ending in `_` takes @@ -2148,10 +2156,6 @@ pub(crate) fn escape(name: &str) -> String { "wchar_t", "xor", "xor_eq", - // Macros GNU dialects predefine, as CMake's default `-std=gnu11` and `-std=gnu++17` do. - "i386", - "linux", - "unix", ]; // `out0`, `out1`, ... are a returned tuple's. let out = name @@ -2159,7 +2163,7 @@ pub(crate) fn escape(name: &str) -> String { .is_some_and(|n| !n.is_empty() && n.chars().all(|c| c.is_ascii_digit())); match name.chars().next() { Some(c) if c.is_ascii_digit() => format!("_{name}"), - _ if out || name.ends_with('_') || KEYWORDS.contains(&name) => format!("{name}_"), + _ if out || name.ends_with('_') || KEYWORDS.contains(&name) || MACROS.contains(&name) => format!("{name}_"), _ => name.to_string(), } } diff --git a/ffi/src/cpp.rs b/ffi/src/cpp.rs index 4f78a99af..a08630045 100644 --- a/ffi/src/cpp.rs +++ b/ffi/src/cpp.rs @@ -2535,12 +2535,10 @@ pub(crate) fn escape(name: &str) -> String { "std", "self", ]; - // Macros GNU dialects predefine, as CMake's default `-std=gnu++17` does. Each name of - // one and trailing `_`s takes another, so `unix` and `unix_` stay apart. - const MACROS: &[&str] = &["i386", "linux", "unix"]; + // Each name of a macro and trailing `_`s takes another, so `unix` and `unix_` stay apart. match name.chars().next() { Some(c) if c.is_ascii_digit() => format!("_{name}"), - _ if KEYWORDS.contains(&name) || MACROS.contains(&name.trim_end_matches('_')) => format!("{name}_"), + _ if KEYWORDS.contains(&name) || abi::MACROS.contains(&name.trim_end_matches('_')) => format!("{name}_"), _ => name.to_string(), } } @@ -2610,6 +2608,9 @@ mod tests { assert_eq!(escape("unix_"), "unix__"); assert_eq!(escape("linux__"), "linux___"); assert_eq!(escape("unixes"), "unixes"); + // And the C library's, which `` and `` define. + assert_eq!(escape("errno"), "errno_"); + assert_eq!(escape("offsetof_"), "offsetof__"); // A keyword keeps its single escape, so a field `type_` stays `type_`. assert_eq!(escape("type_"), "type_"); } diff --git a/ffi/src/glue.rs b/ffi/src/glue.rs index ab4faad9b..d0617bb85 100644 --- a/ffi/src/glue.rs +++ b/ffi/src/glue.rs @@ -66,9 +66,13 @@ fn dependency(krate: &str) -> String { } /// The name the crate depends on a crate the facade does not re-export by, apart from the -/// facade's even when they share a name. +/// facade's even when they share a name. `bytes` is the crate's own too, which cargo refuses +/// to depend on twice under two names, so it keeps its own. fn reached(krate: &str) -> String { - format!("{krate}_reached") + match krate { + "bytes" => krate.to_string(), + _ => format!("{krate}_reached"), + } } /// The name the crate depends on a foreign type's crate by, apart from the facade's even @@ -319,8 +323,15 @@ impl Crate<'_> { r.krate )); }; - let line = format!("{} = {}\n", reached(&r.krate), paths.dependency(keys)?); - match r.targets == api.targets { + // The crate's own `bytes` keeps the default features the glue builds it with. + let line = format!( + "{} = {}\n", + reached(&r.krate), + paths.dependency(keys, r.krate != "bytes")? + ); + // The glue's own `Bytes` is the facade's, on every target: cargo refuses one name + // from two sources, and a `path` or `git` source has one for all targets. + match r.targets == api.targets || r.krate == "bytes" { true => every.push_str(&line), false => (r.targets.iter()).for_each(|t| targeted.entry(t).or_default().push_str(&line)), } @@ -328,7 +339,12 @@ impl Crate<'_> { let targeted: String = (targeted.into_iter()) .map(|(target, lines)| format!("[target.{target:?}.dependencies]\n{lines}\n")) .collect(); - let dependencies = format!("{dependencies}{foreign}{every}"); + // The crate's own `bytes`, unless the facade's stands for it. + let own = match api.reached.iter().any(|r| r.krate == "bytes") { + true => "", + false => "bytes = \"1\"\n", + }; + let dependencies = format!("{dependencies}{foreign}{every}{own}"); // The facade's oldest toolchain is the crate's, which cargo sets as rustc compiles it, // though no older than the crate's edition needs; cargo checks the value's form. let rust_version = match std::env::var("CARGO_PKG_RUST_VERSION") { @@ -356,7 +372,6 @@ impl Crate<'_> { \n\ [dependencies]\n\ {dependencies}\ - bytes = \"1\"\n\ jni-sys = {{ version = \"0.4\", optional = true }}\n\ pyo3-ffi = {{ version = \"0.30\", optional = true, features = [\"abi3-py311\", \"extension-module\"] }}\n\ smallvec = {{ version = \"1.16\", optional = true }}\n\ @@ -583,14 +598,17 @@ impl Paths { Ok(relative(out, &lexical(&plain(&spelled))).unwrap_or_else(|| dir.display().to_string())) } - /// The inline table of the dependency whose keys are `keys`, without default features. - fn dependency(&self, keys: &str) -> Result { + /// The inline table of the dependency whose keys are `keys`, without default features + /// when `bare`. + fn dependency(&self, keys: &str, bare: bool) -> Result { let mut table: toml::Table = toml::from_str(&format!("dependency = {{ {keys} }}")) .map_err(|err| format!("reading the dependency `{keys}`: {err}"))?; self.relocate(&mut table)?; let dependency = table.get_mut("dependency").and_then(|d| d.as_table_mut()); let dependency = dependency.expect("the table written above"); - dependency.insert("default-features".to_string(), false.into()); + if bare { + dependency.insert("default-features".to_string(), false.into()); + } Ok(toml::Value::Table(dependency.clone()).to_string()) } @@ -3511,15 +3529,15 @@ fn manifest_paths_are_relative_to_the_export() { ); assert_eq!( paths - .dependency(&format!( - "package = \"other\", path = {:?}", - other.display().to_string() - )) + .dependency( + &format!("package = \"other\", path = {:?}", other.display().to_string()), + true + ) .unwrap(), "{ default-features = false, package = \"other\", path = \"../source/other\" }" ); assert_eq!( - paths.dependency("package = \"x\", version = \"=1.0.0\"").unwrap(), + paths.dependency("package = \"x\", version = \"=1.0.0\"", true).unwrap(), "{ default-features = false, package = \"x\", version = \"=1.0.0\" }" ); #[cfg(unix)] diff --git a/ffi/src/kotlin.rs b/ffi/src/kotlin.rs index b14b03a86..c222bb943 100644 --- a/ffi/src/kotlin.rs +++ b/ffi/src/kotlin.rs @@ -489,15 +489,16 @@ class Bytes private constructor( /// The names the generated code uses unqualified, which no exported type or function may /// take. The runtime's helper classes, which `_Native` nests, take a leading `__`, which /// neither an exported type's name nor its `_` import alias in the glue has, so they -/// need no place here. The runtime's own are the C ABI's: `Native`, `Waker`, `Bytes`, `Mut`, -/// and `Bound` are claimed as `_native`, `_waker`, `_bytes`, -/// `_mut`, and `_bound`. +/// need no place here. The runtime's own top-level classes do, as one in the package an +/// export of the same name would redeclare: `Bytes`, `Waker`, `Mut`, and `Bound`. const TAKEN: &[&str] = &[ "Any", "AutoCloseable", "Boolean", + "Bound", "Byte", "ByteArray", + "Bytes", "Double", "DoubleArray", "Duration", @@ -511,6 +512,7 @@ const TAKEN: &[&str] = &[ "Ipv6Addr", "Long", "LongArray", + "Mut", "PathBuf", "Short", "ShortArray", @@ -527,6 +529,7 @@ const TAKEN: &[&str] = &[ "UShort", "UShortArray", "Unit", + "Waker", "also", "check", "error", diff --git a/ffi/surface/api/c.h b/ffi/surface/api/c.h index 10fa0a166..a8ab6ae04 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)0x803114fce319dd8dULL) +#define API_CONTRACT ((uint64_t)0x06b4a9cf5dcdd72bULL) uint64_t api_contract(void); uint32_t api_target(void); typedef int32_t api_status; @@ -859,6 +859,12 @@ typedef struct api_Knob { typedef struct api_polar_Turn { uint8_t part; } api_polar_Turn; +typedef struct api_macros_Streams { + uint8_t stdin_; + uint8_t stdout_; + uint8_t stderr_; + uint8_t errno_; +} api_macros_Streams; typedef struct api_clash_TONE { uint8_t db; } api_clash_TONE; @@ -1403,6 +1409,9 @@ API_MUST_USE api_buf api_polar_Point_debug(const api_polar_Point *self); void api_polar_Turn_free(api_polar_Turn *self); bool api_polar_Turn_eq(const api_polar_Turn *a, const api_polar_Turn *b); API_MUST_USE api_buf api_polar_Turn_debug(const api_polar_Turn *self); +void api_macros_Streams_free(api_macros_Streams *self); +bool api_macros_Streams_eq(const api_macros_Streams *a, const api_macros_Streams *b); +API_MUST_USE api_buf api_macros_Streams_debug(const api_macros_Streams *self); void api_clash_Tone_free(api_clash_Tone *self); bool api_clash_Tone_eq(const api_clash_Tone *a, const api_clash_Tone *b); API_MUST_USE api_buf api_clash_Tone_debug(const api_clash_Tone *self); @@ -2442,6 +2451,9 @@ uint64_t api_booth_count(api_Booth booth, api_status *status); api_Page api_page(void); uint32_t api_beats(api_Beat beat); int32_t api_same(double a, double b); +int32_t api_errno(void); +bool api_assert(bool holds); +uint8_t api_offsetof(uint8_t field); API_MUST_USE bool api_return_values(api_Point point, bool fail, api_Point *point_out, api_buf *out0, api_option_tuple_u8_i16_u32_u64 *out1, api_vec_bytes *out2, api_Error *err); API_MUST_USE bool api_return_moved(api_Counter *counter, bool fail, api_Counter **out, api_Error *err, api_status *status); api_NonZeros api_non_zeros(void); @@ -2484,6 +2496,7 @@ uint64_t api_crowded(api_Reading reading, api_Stamp a, api_Stamp b, uint64_t n0, uint64_t api_crammed(api_Moment a, api_Moment b, uint64_t n0, uint64_t n1, uint64_t n2, uint64_t n3, uint64_t n4, uint64_t n5, uint64_t n6, uint64_t n7, uint64_t n8, uint64_t n9, uint64_t n10, uint64_t n11, uint64_t n12, uint64_t n13, uint64_t n14, uint64_t n15, uint64_t n16, uint64_t n17, uint64_t n18, uint64_t n19, uint64_t n20, uint64_t n21, uint64_t n22, uint64_t n23, uint64_t n24, uint64_t n25, uint64_t n26, uint64_t n27, uint64_t n28, uint64_t n29, uint64_t n30, uint64_t n31, uint64_t n32, uint64_t n33, uint64_t n34, uint64_t n35, uint64_t n36, uint64_t n37, uint64_t n38, uint64_t n39, uint64_t n40, uint64_t n41, uint64_t n42, uint64_t n43, uint64_t n44, uint64_t n45, uint64_t n46, uint64_t n47, uint64_t n48, uint64_t n49, uint64_t n50, uint64_t n51, uint64_t n52, uint64_t n53, uint64_t n54, uint64_t n55, uint64_t n56, uint64_t n57, uint64_t n58, uint64_t n59, uint64_t n60, uint64_t n61, uint64_t n62, uint64_t n63, uint64_t n64, uint64_t n65, uint64_t n66, uint64_t n67, uint64_t n68, uint64_t n69, uint64_t n70, uint64_t n71, uint64_t n72, uint64_t n73, uint64_t n74, uint64_t n75, uint64_t n76, uint64_t n77, uint64_t n78, uint64_t n79, uint64_t n80, uint64_t n81, uint64_t n82, uint64_t n83, uint64_t n84, uint64_t n85, uint64_t n86, uint64_t n87, uint64_t n88, uint64_t n89, uint64_t n90, uint64_t n91, uint64_t n92, uint64_t n93, uint64_t n94, uint64_t n95, uint64_t n96, uint64_t n97, uint64_t n98, uint64_t n99, uint64_t n100, uint64_t n101, uint64_t n102, uint64_t n103, uint64_t n104, uint64_t n105, uint64_t n106, uint64_t n107, uint64_t n108, uint64_t n109, uint64_t n110, uint64_t n111, uint64_t n112, uint64_t n113, uint64_t n114, uint64_t n115, uint64_t n116, uint64_t n117, uint64_t n118, uint64_t n119, uint64_t n120, uint64_t n121, uint64_t n122, uint64_t n123); uint32_t api_jni_one(void); api_option_polar_Point api_polar_point(uint32_t distance); +uint32_t api_macros_streamed(api_macros_Streams streams, uint8_t errno_); API_MUST_USE api_clash_Any api_clash_any(api_buf type_url); api_clash_Candidate api_clash_candidate(uint8_t at); uint8_t api_clash_ignore(uint8_t arg0, uint8_t arg1, uint8_t arg2); diff --git a/ffi/surface/api/cpp.hpp b/ffi/surface/api/cpp.hpp index 6ad680ed4..354bbb087 100644 --- a/ffi/surface/api/cpp.hpp +++ b/ffi/surface/api/cpp.hpp @@ -1201,6 +1201,15 @@ namespace api { friend bool operator!=(const polar_Turn &a__, const polar_Turn &b_); ::api::buf debug() const; }; + struct macros_Streams { + ::std::uint8_t stdin_; + ::std::uint8_t stdout_; + ::std::uint8_t stderr_; + ::std::uint8_t errno_; + friend bool operator==(const macros_Streams &a__, const macros_Streams &b_); + friend bool operator!=(const macros_Streams &a__, const macros_Streams &b_); + ::api::buf debug() const; + }; struct clash_Tone { ::std::uint16_t hz; friend bool operator==(const clash_Tone &a__, const clash_Tone &b_); @@ -1435,6 +1444,7 @@ namespace api { inline bool operator==(const Knob &a__, const Knob &b_); 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 macros_Streams &a__, const macros_Streams &b_); inline bool operator==(const clash_Tone &a__, const clash_Tone &b_); inline bool operator==(const clash_TONE &a__, const clash_TONE &b_); inline bool operator==(const clash_Span &a__, const clash_Span &b_); @@ -1750,6 +1760,9 @@ namespace api { inline ::api::Page page(); inline ::std::uint32_t beats(::std::unique_ptr<::api::Beat> beat); inline ::std::int32_t same(double a__, double b_); + inline ::std::int32_t errno_(); + inline bool assert_(bool holds); + inline ::std::uint8_t offsetof_(::std::uint8_t field); inline ::api::result<::std::tuple<::api::buf, ::std::optional<::std::tuple<::std::uint8_t, ::std::int16_t, ::std::uint32_t, ::std::uint64_t>>, ::std::vector<::api::buf>>, ::api::Error> return_values(::api::Point &point, bool fail); inline ::api::result<::api::Counter, ::api::Error> return_moved(::api::Counter counter, bool fail); inline ::api::NonZeros non_zeros(); @@ -1780,6 +1793,7 @@ namespace api { inline ::std::uint64_t crammed(const ::api::Moment &a__, const ::api::Moment &b_, ::std::uint64_t n0, ::std::uint64_t n1, ::std::uint64_t n2, ::std::uint64_t n3, ::std::uint64_t n4, ::std::uint64_t n5, ::std::uint64_t n6, ::std::uint64_t n7, ::std::uint64_t n8, ::std::uint64_t n9, ::std::uint64_t n10, ::std::uint64_t n11, ::std::uint64_t n12, ::std::uint64_t n13, ::std::uint64_t n14, ::std::uint64_t n15, ::std::uint64_t n16, ::std::uint64_t n17, ::std::uint64_t n18, ::std::uint64_t n19, ::std::uint64_t n20, ::std::uint64_t n21, ::std::uint64_t n22, ::std::uint64_t n23, ::std::uint64_t n24, ::std::uint64_t n25, ::std::uint64_t n26, ::std::uint64_t n27, ::std::uint64_t n28, ::std::uint64_t n29, ::std::uint64_t n30, ::std::uint64_t n31, ::std::uint64_t n32, ::std::uint64_t n33, ::std::uint64_t n34, ::std::uint64_t n35, ::std::uint64_t n36, ::std::uint64_t n37, ::std::uint64_t n38, ::std::uint64_t n39, ::std::uint64_t n40, ::std::uint64_t n41, ::std::uint64_t n42, ::std::uint64_t n43, ::std::uint64_t n44, ::std::uint64_t n45, ::std::uint64_t n46, ::std::uint64_t n47, ::std::uint64_t n48, ::std::uint64_t n49, ::std::uint64_t n50, ::std::uint64_t n51, ::std::uint64_t n52, ::std::uint64_t n53, ::std::uint64_t n54, ::std::uint64_t n55, ::std::uint64_t n56, ::std::uint64_t n57, ::std::uint64_t n58, ::std::uint64_t n59, ::std::uint64_t n60, ::std::uint64_t n61, ::std::uint64_t n62, ::std::uint64_t n63, ::std::uint64_t n64, ::std::uint64_t n65, ::std::uint64_t n66, ::std::uint64_t n67, ::std::uint64_t n68, ::std::uint64_t n69, ::std::uint64_t n70, ::std::uint64_t n71, ::std::uint64_t n72, ::std::uint64_t n73, ::std::uint64_t n74, ::std::uint64_t n75, ::std::uint64_t n76, ::std::uint64_t n77, ::std::uint64_t n78, ::std::uint64_t n79, ::std::uint64_t n80, ::std::uint64_t n81, ::std::uint64_t n82, ::std::uint64_t n83, ::std::uint64_t n84, ::std::uint64_t n85, ::std::uint64_t n86, ::std::uint64_t n87, ::std::uint64_t n88, ::std::uint64_t n89, ::std::uint64_t n90, ::std::uint64_t n91, ::std::uint64_t n92, ::std::uint64_t n93, ::std::uint64_t n94, ::std::uint64_t n95, ::std::uint64_t n96, ::std::uint64_t n97, ::std::uint64_t n98, ::std::uint64_t n99, ::std::uint64_t n100, ::std::uint64_t n101, ::std::uint64_t n102, ::std::uint64_t n103, ::std::uint64_t n104, ::std::uint64_t n105, ::std::uint64_t n106, ::std::uint64_t n107, ::std::uint64_t n108, ::std::uint64_t n109, ::std::uint64_t n110, ::std::uint64_t n111, ::std::uint64_t n112, ::std::uint64_t n113, ::std::uint64_t n114, ::std::uint64_t n115, ::std::uint64_t n116, ::std::uint64_t n117, ::std::uint64_t n118, ::std::uint64_t n119, ::std::uint64_t n120, ::std::uint64_t n121, ::std::uint64_t n122, ::std::uint64_t n123); inline ::std::uint32_t jni_one(); inline ::std::optional<::api::polar_Point> polar_point(::std::uint32_t distance); + inline ::std::uint32_t macros_streamed(const ::api::macros_Streams &streams, ::std::uint8_t errno_); inline ::api::clash_Any clash_any(::api::input type_url); inline ::api::clash_Candidate clash_candidate(::std::uint8_t at); inline ::std::uint8_t clash_ignore(::std::uint8_t arg0, ::std::uint8_t arg1, ::std::uint8_t arg2); @@ -2168,6 +2182,7 @@ namespace api { struct Knob; struct polar_Point; struct polar_Turn; + struct macros_Streams; struct clash_Tone; struct clash_TONE; struct clash_Span; diff --git a/ffi/surface/api/dart.dart b/ffi/surface/api/dart.dart index 9512224cb..37fa94869 100644 --- a/ffi/surface/api/dart.dart +++ b/ffi/surface/api/dart.dart @@ -685,6 +685,16 @@ final class PolarTurn2 { @override bool operator ==(Object other); @override int get hashCode; } +final class MacrosStreams { + final int stdin; + final int stdout; + final int stderr; + final int errno; + const MacrosStreams({required this.stdin, required this.stdout, required this.stderr, required this.errno}); + String debug(); + @override bool operator ==(Object other); + @override int get hashCode; +} final class ClashTone { final int hz; const ClashTone({required this.hz}); @@ -1898,6 +1908,9 @@ U64 boothCount(Booth booth); Page page(); int beats(Beat beat); int same(double a, double b); +int errno(); +bool assert_(bool holds); +int offsetof(int field); (String, (int, int, int, U64)?, List) returnValues(Mut point, bool fail); Counter returnMoved(Counter counter, bool fail); NonZeros nonZeros(); @@ -1928,6 +1941,7 @@ U64 crowded(Reading reading, Stamp a, Stamp b, U64 n0, U64 n1, U64 n2, U64 n3, U U64 crammed(Moment a, Moment b, U64 n0, U64 n1, U64 n2, U64 n3, U64 n4, U64 n5, U64 n6, U64 n7, U64 n8, U64 n9, U64 n10, U64 n11, U64 n12, U64 n13, U64 n14, U64 n15, U64 n16, U64 n17, U64 n18, U64 n19, U64 n20, U64 n21, U64 n22, U64 n23, U64 n24, U64 n25, U64 n26, U64 n27, U64 n28, U64 n29, U64 n30, U64 n31, U64 n32, U64 n33, U64 n34, U64 n35, U64 n36, U64 n37, U64 n38, U64 n39, U64 n40, U64 n41, U64 n42, U64 n43, U64 n44, U64 n45, U64 n46, U64 n47, U64 n48, U64 n49, U64 n50, U64 n51, U64 n52, U64 n53, U64 n54, U64 n55, U64 n56, U64 n57, U64 n58, U64 n59, U64 n60, U64 n61, U64 n62, U64 n63, U64 n64, U64 n65, U64 n66, U64 n67, U64 n68, U64 n69, U64 n70, U64 n71, U64 n72, U64 n73, U64 n74, U64 n75, U64 n76, U64 n77, U64 n78, U64 n79, U64 n80, U64 n81, U64 n82, U64 n83, U64 n84, U64 n85, U64 n86, U64 n87, U64 n88, U64 n89, U64 n90, U64 n91, U64 n92, U64 n93, U64 n94, U64 n95, U64 n96, U64 n97, U64 n98, U64 n99, U64 n100, U64 n101, U64 n102, U64 n103, U64 n104, U64 n105, U64 n106, U64 n107, U64 n108, U64 n109, U64 n110, U64 n111, U64 n112, U64 n113, U64 n114, U64 n115, U64 n116, U64 n117, U64 n118, U64 n119, U64 n120, U64 n121, U64 n122, U64 n123); int jniOne(); PolarPoint? polarPoint(int distance); +int macrosStreamed(MacrosStreams streams, int errno); ClashAny clashAny(String typeUrl); ClashCandidate clashCandidate(int at); int clashIgnore(int arg0, int arg1, int arg2); diff --git a/ffi/surface/api/go.txt b/ffi/surface/api/go.txt index 29de35221..6fa1755d6 100644 --- a/ffi/surface/api/go.txt +++ b/ffi/surface/api/go.txt @@ -15,6 +15,7 @@ func ApplyNonZeroU16(pair PairNonZeroU16, f func(uint16) uint32) (uint32, error) func ApplyU32(pair PairU32, f func(uint32) uint32) uint32 func Area(size p_dep.Size) uint64 func AreaScaledPoint(self *p_dep.Area, by Point) (uint64, error) +func Assert(holds bool) bool func Attempt(check func() error) error func BeatVtable_() unsafe.Pointer func Beats(beat Beat) (uint32, error) @@ -73,6 +74,7 @@ func End(limit uint64) p_rt.BoundU64 func Ends(limit uint64) (p_rt.BoundU64, p_rt.BoundU64) func Entries(entries []p_rt.Tuple2[string, *p_serdejson.Json], tag string) ([]p_rt.Tuple2[string, *p_serdejson.Json], error) func Erased(receipt *Receipt) (uint32, error) +func Errno() int32 func Excuse(note p_rt.Bytes, entry p_rt.Tuple2[p_rt.Bytes, *Refusal]) (uint, error) func Extended(duration p_rt.Duration, by p_rt.Duration) *p_rt.Duration func Failure(message string) (*p_core.IoError, error) @@ -132,6 +134,7 @@ func LogVtable_() unsafe.Pointer func LogWaker(log Log) (func(), error) func Longest(words []string) (uint, error) func Louder(filter *p_tracingcore.Level) *p_tracingcore.Level +func MacrosStreamed(streams MacrosStreams, errno uint8) uint32 func Made(n uint32, make_ func(uint32) string) string func Marked(apiMarked *Mark) (uint64, error) func MarkerY() int32 @@ -145,6 +148,7 @@ func Nudge(point *Point, by int32) func NudgeBy(point *Point, refusal *Refusal) error func OfferedLen(alpns []p_rt.Bytes) uint func Offset(by func() uint32, byData uint32) uint32 +func Offsetof(field uint8) uint8 func OnFirstThread() bool func PRIMES() []uint32 func Parents(paths []string) ([]*string, error) @@ -1140,6 +1144,14 @@ func (self LongArray) Also(f func(uint64)) func (self LongArray) C() uint64 func (self LongArray) Equal(other LongArray) bool func (self LongArray) GoString() string +type MacrosStreams struct { + Stdin uint8 + Stdout uint8 + Stderr uint8 + Errno uint8 +} +func (self MacrosStreams) Equal(other MacrosStreams) bool +func (self MacrosStreams) GoString() string type Mark struct { Handle_ *p_rt.Handle_ } diff --git a/ffi/surface/api/kotlin.kt b/ffi/surface/api/kotlin.kt index b09286a56..2e51b7a18 100644 --- a/ffi/surface/api/kotlin.kt +++ b/ffi/surface/api/kotlin.kt @@ -407,6 +407,9 @@ data class PolarPoint(val turns: kotlin.UByte, val distance: kotlin.UInt) { data class Polar_Turn(val part: kotlin.UByte) { fun debug(): kotlin.String } +data class MacrosStreams(val stdin: kotlin.UByte, val stdout: kotlin.UByte, val stderr: kotlin.UByte, val errno: kotlin.UByte) { + fun debug(): kotlin.String +} data class ClashTone(val hz: kotlin.UShort) { fun debug(): kotlin.String } @@ -1649,6 +1652,9 @@ fun boothCount(booth: api.Booth): kotlin.ULong fun page(): api.Page fun beats(beat: api.Beat): kotlin.UInt fun same(a: kotlin.Double, b: kotlin.Double): kotlin.Int +fun errno(): kotlin.Int +fun assert(holds: kotlin.Boolean): kotlin.Boolean +fun offsetof(field: kotlin.UByte): kotlin.UByte @kotlin.jvm.Throws(ErrorException::class) fun returnValues(point: api.Mut, fail: kotlin.Boolean): kotlin.Triple?, kotlin.collections.List> @kotlin.jvm.Throws(ErrorException::class) fun returnMoved(counter: api.Counter, fail: kotlin.Boolean): api.Counter fun nonZeros(): api.NonZeros @@ -1679,6 +1685,7 @@ fun crowded(reading: api.Reading, a: api.Stamp, b: api.Stamp, n0: kotlin.ULong, fun crammed(a: api.Moment, b: api.Moment, n0: kotlin.ULong, n1: kotlin.ULong, n2: kotlin.ULong, n3: kotlin.ULong, n4: kotlin.ULong, n5: kotlin.ULong, n6: kotlin.ULong, n7: kotlin.ULong, n8: kotlin.ULong, n9: kotlin.ULong, n10: kotlin.ULong, n11: kotlin.ULong, n12: kotlin.ULong, n13: kotlin.ULong, n14: kotlin.ULong, n15: kotlin.ULong, n16: kotlin.ULong, n17: kotlin.ULong, n18: kotlin.ULong, n19: kotlin.ULong, n20: kotlin.ULong, n21: kotlin.ULong, n22: kotlin.ULong, n23: kotlin.ULong, n24: kotlin.ULong, n25: kotlin.ULong, n26: kotlin.ULong, n27: kotlin.ULong, n28: kotlin.ULong, n29: kotlin.ULong, n30: kotlin.ULong, n31: kotlin.ULong, n32: kotlin.ULong, n33: kotlin.ULong, n34: kotlin.ULong, n35: kotlin.ULong, n36: kotlin.ULong, n37: kotlin.ULong, n38: kotlin.ULong, n39: kotlin.ULong, n40: kotlin.ULong, n41: kotlin.ULong, n42: kotlin.ULong, n43: kotlin.ULong, n44: kotlin.ULong, n45: kotlin.ULong, n46: kotlin.ULong, n47: kotlin.ULong, n48: kotlin.ULong, n49: kotlin.ULong, n50: kotlin.ULong, n51: kotlin.ULong, n52: kotlin.ULong, n53: kotlin.ULong, n54: kotlin.ULong, n55: kotlin.ULong, n56: kotlin.ULong, n57: kotlin.ULong, n58: kotlin.ULong, n59: kotlin.ULong, n60: kotlin.ULong, n61: kotlin.ULong, n62: kotlin.ULong, n63: kotlin.ULong, n64: kotlin.ULong, n65: kotlin.ULong, n66: kotlin.ULong, n67: kotlin.ULong, n68: kotlin.ULong, n69: kotlin.ULong, n70: kotlin.ULong, n71: kotlin.ULong, n72: kotlin.ULong, n73: kotlin.ULong, n74: kotlin.ULong, n75: kotlin.ULong, n76: kotlin.ULong, n77: kotlin.ULong, n78: kotlin.ULong, n79: kotlin.ULong, n80: kotlin.ULong, n81: kotlin.ULong, n82: kotlin.ULong, n83: kotlin.ULong, n84: kotlin.ULong, n85: kotlin.ULong, n86: kotlin.ULong, n87: kotlin.ULong, n88: kotlin.ULong, n89: kotlin.ULong, n90: kotlin.ULong, n91: kotlin.ULong, n92: kotlin.ULong, n93: kotlin.ULong, n94: kotlin.ULong, n95: kotlin.ULong, n96: kotlin.ULong, n97: kotlin.ULong, n98: kotlin.ULong, n99: kotlin.ULong, n100: kotlin.ULong, n101: kotlin.ULong, n102: kotlin.ULong, n103: kotlin.ULong, n104: kotlin.ULong, n105: kotlin.ULong, n106: kotlin.ULong, n107: kotlin.ULong, n108: kotlin.ULong, n109: kotlin.ULong, n110: kotlin.ULong, n111: kotlin.ULong, n112: kotlin.ULong, n113: kotlin.ULong, n114: kotlin.ULong, n115: kotlin.ULong, n116: kotlin.ULong, n117: kotlin.ULong, n118: kotlin.ULong, n119: kotlin.ULong, n120: kotlin.ULong, n121: kotlin.ULong, n122: kotlin.ULong, n123: kotlin.ULong): kotlin.ULong fun jniOne(): kotlin.UInt fun polarPoint(distance: kotlin.UInt): api.PolarPoint? +fun macrosStreamed(streams: api.MacrosStreams, errno: kotlin.UByte): kotlin.UInt fun clashAny(typeUrl: kotlin.String): api.ClashAny fun clashCandidate(at: kotlin.UByte): api.ClashCandidate fun clashIgnore(arg0: kotlin.UByte, arg1: kotlin.UByte, arg2: kotlin.UByte): kotlin.UByte diff --git a/ffi/surface/api/python.pyi b/ffi/surface/api/python.pyi index 77dd5615f..5fb6c4fae 100644 --- a/ffi/surface/api/python.pyi +++ b/ffi/surface/api/python.pyi @@ -483,6 +483,14 @@ class Polar_Turn(_Record): def __init__(self, part: _int) -> None: ... def __eq__(self, other: _object) -> _bool: ... def __repr__(self) -> _str: ... +class MacrosStreams(_Record): + stdin: _int + stdout: _int + stderr: _int + errno: _int + def __init__(self, stdin: _int, stdout: _int, stderr: _int, errno: _int) -> None: ... + def __eq__(self, other: _object) -> _bool: ... + def __repr__(self) -> _str: ... class ClashTone(_Record): hz: _int def __init__(self, hz: _int) -> None: ... @@ -1705,6 +1713,9 @@ def booth_count(booth: Booth) -> _int: ... def page() -> Page: ... def beats(beat: Beat) -> _int: ... def same(a: _float, b: _float) -> _int: ... +def errno() -> _int: ... +def assert_(holds: _bool) -> _bool: ... +def offsetof(field: _int) -> _int: ... def return_values(point: Mut[Point], fail: _bool) -> _tuple[_str, _tuple[_int, _int, _int, _int] | None, _list[_memoryview]]: ... def return_moved(counter: Counter, fail: _bool) -> Counter: ... def non_zeros() -> NonZeros: ... @@ -1733,6 +1744,7 @@ def crowded(reading: Reading, a: Stamp, b: Stamp, n0: _int, n1: _int, n2: _int, def crammed(a: Moment, b: Moment, n0: _int, n1: _int, n2: _int, n3: _int, n4: _int, n5: _int, n6: _int, n7: _int, n8: _int, n9: _int, n10: _int, n11: _int, n12: _int, n13: _int, n14: _int, n15: _int, n16: _int, n17: _int, n18: _int, n19: _int, n20: _int, n21: _int, n22: _int, n23: _int, n24: _int, n25: _int, n26: _int, n27: _int, n28: _int, n29: _int, n30: _int, n31: _int, n32: _int, n33: _int, n34: _int, n35: _int, n36: _int, n37: _int, n38: _int, n39: _int, n40: _int, n41: _int, n42: _int, n43: _int, n44: _int, n45: _int, n46: _int, n47: _int, n48: _int, n49: _int, n50: _int, n51: _int, n52: _int, n53: _int, n54: _int, n55: _int, n56: _int, n57: _int, n58: _int, n59: _int, n60: _int, n61: _int, n62: _int, n63: _int, n64: _int, n65: _int, n66: _int, n67: _int, n68: _int, n69: _int, n70: _int, n71: _int, n72: _int, n73: _int, n74: _int, n75: _int, n76: _int, n77: _int, n78: _int, n79: _int, n80: _int, n81: _int, n82: _int, n83: _int, n84: _int, n85: _int, n86: _int, n87: _int, n88: _int, n89: _int, n90: _int, n91: _int, n92: _int, n93: _int, n94: _int, n95: _int, n96: _int, n97: _int, n98: _int, n99: _int, n100: _int, n101: _int, n102: _int, n103: _int, n104: _int, n105: _int, n106: _int, n107: _int, n108: _int, n109: _int, n110: _int, n111: _int, n112: _int, n113: _int, n114: _int, n115: _int, n116: _int, n117: _int, n118: _int, n119: _int, n120: _int, n121: _int, n122: _int, n123: _int) -> _int: ... def jni_one() -> _int: ... def polar_point(distance: _int) -> PolarPoint | None: ... +def macros_streamed(streams: MacrosStreams, errno: _int) -> _int: ... def clash_any(type_url: _str) -> ClashAny: ... def clash_candidate(at: _int) -> ClashCandidate: ... def clash_ignore(arg0: _int, arg1: _int, arg2: _int) -> _int: ... @@ -1969,6 +1981,9 @@ booth_count = _n.booth_count page = _n.page beats = _n.beats same = _n.same +errno = _n.errno +assert_ = _n.assert_ +offsetof = _n.offsetof return_values = _n.return_values return_moved = _n.return_moved non_zeros = _n.non_zeros @@ -1996,6 +2011,7 @@ crowded = _n.crowded crammed = _n.crammed jni_one = _n.jni_one polar_point = _n.polar_point +macros_streamed = _n.macros_streamed clash_any = _n.clash_any clash_candidate = _n.clash_candidate clash_ignore = _n.clash_ignore diff --git a/ffi/surface/api/swift.swift b/ffi/surface/api/swift.swift index f2f3fbbd1..41e70dc3f 100644 --- a/ffi/surface/api/swift.swift +++ b/ffi/surface/api/swift.swift @@ -639,6 +639,15 @@ public struct Polar_Turn: Sendable, CustomDebugStringConvertible, Equatable { @inlinable public var debugDescription: Swift.String { get } @inlinable public static func == (a: Polar_Turn, b: Polar_Turn) -> Swift.Bool } +public struct MacrosStreams: Sendable, CustomDebugStringConvertible, Equatable { + public var stdin: Swift.UInt8 + public var stdout: Swift.UInt8 + public var stderr: Swift.UInt8 + public var errno: Swift.UInt8 + @inlinable public init(stdin: Swift.UInt8, stdout: Swift.UInt8, stderr: Swift.UInt8, errno: Swift.UInt8) + @inlinable public var debugDescription: Swift.String { get } + @inlinable public static func == (a: MacrosStreams, b: MacrosStreams) -> Swift.Bool +} public struct ClashTone: Sendable, CustomDebugStringConvertible, Equatable { public var hz: Swift.UInt16 @inlinable public init(hz: Swift.UInt16) @@ -1725,6 +1734,9 @@ public let URL: Swift.UInt64 @inlinable public func page() throws -> Page @inlinable public func beats(_ beat: any Beat) throws -> Swift.UInt32 @inlinable public func same(_ a: Swift.Double, _ b: Swift.Double) -> Swift.Int32 +@inlinable public func errno() -> Swift.Int32 +@inlinable public func assert(_ holds: Swift.Bool) -> Swift.Bool +@inlinable public func offsetof(_ field: Swift.UInt8) -> Swift.UInt8 @inlinable public func returnValues(_ point: inout Point, _ fail: Swift.Bool) throws -> (Swift.String, (Swift.UInt8, Swift.Int16, Swift.UInt32, Swift.UInt64)?, [Bytes]) @inlinable public func returnMoved(_ counter: consuming Counter, _ fail: Swift.Bool) throws -> Counter @inlinable public func nonZeros() -> NonZeros @@ -1755,6 +1767,7 @@ public let URL: Swift.UInt64 @inlinable public func crammed(_ a: Moment, _ b: Moment, _ n0: Swift.UInt64, _ n1: Swift.UInt64, _ n2: Swift.UInt64, _ n3: Swift.UInt64, _ n4: Swift.UInt64, _ n5: Swift.UInt64, _ n6: Swift.UInt64, _ n7: Swift.UInt64, _ n8: Swift.UInt64, _ n9: Swift.UInt64, _ n10: Swift.UInt64, _ n11: Swift.UInt64, _ n12: Swift.UInt64, _ n13: Swift.UInt64, _ n14: Swift.UInt64, _ n15: Swift.UInt64, _ n16: Swift.UInt64, _ n17: Swift.UInt64, _ n18: Swift.UInt64, _ n19: Swift.UInt64, _ n20: Swift.UInt64, _ n21: Swift.UInt64, _ n22: Swift.UInt64, _ n23: Swift.UInt64, _ n24: Swift.UInt64, _ n25: Swift.UInt64, _ n26: Swift.UInt64, _ n27: Swift.UInt64, _ n28: Swift.UInt64, _ n29: Swift.UInt64, _ n30: Swift.UInt64, _ n31: Swift.UInt64, _ n32: Swift.UInt64, _ n33: Swift.UInt64, _ n34: Swift.UInt64, _ n35: Swift.UInt64, _ n36: Swift.UInt64, _ n37: Swift.UInt64, _ n38: Swift.UInt64, _ n39: Swift.UInt64, _ n40: Swift.UInt64, _ n41: Swift.UInt64, _ n42: Swift.UInt64, _ n43: Swift.UInt64, _ n44: Swift.UInt64, _ n45: Swift.UInt64, _ n46: Swift.UInt64, _ n47: Swift.UInt64, _ n48: Swift.UInt64, _ n49: Swift.UInt64, _ n50: Swift.UInt64, _ n51: Swift.UInt64, _ n52: Swift.UInt64, _ n53: Swift.UInt64, _ n54: Swift.UInt64, _ n55: Swift.UInt64, _ n56: Swift.UInt64, _ n57: Swift.UInt64, _ n58: Swift.UInt64, _ n59: Swift.UInt64, _ n60: Swift.UInt64, _ n61: Swift.UInt64, _ n62: Swift.UInt64, _ n63: Swift.UInt64, _ n64: Swift.UInt64, _ n65: Swift.UInt64, _ n66: Swift.UInt64, _ n67: Swift.UInt64, _ n68: Swift.UInt64, _ n69: Swift.UInt64, _ n70: Swift.UInt64, _ n71: Swift.UInt64, _ n72: Swift.UInt64, _ n73: Swift.UInt64, _ n74: Swift.UInt64, _ n75: Swift.UInt64, _ n76: Swift.UInt64, _ n77: Swift.UInt64, _ n78: Swift.UInt64, _ n79: Swift.UInt64, _ n80: Swift.UInt64, _ n81: Swift.UInt64, _ n82: Swift.UInt64, _ n83: Swift.UInt64, _ n84: Swift.UInt64, _ n85: Swift.UInt64, _ n86: Swift.UInt64, _ n87: Swift.UInt64, _ n88: Swift.UInt64, _ n89: Swift.UInt64, _ n90: Swift.UInt64, _ n91: Swift.UInt64, _ n92: Swift.UInt64, _ n93: Swift.UInt64, _ n94: Swift.UInt64, _ n95: Swift.UInt64, _ n96: Swift.UInt64, _ n97: Swift.UInt64, _ n98: Swift.UInt64, _ n99: Swift.UInt64, _ n100: Swift.UInt64, _ n101: Swift.UInt64, _ n102: Swift.UInt64, _ n103: Swift.UInt64, _ n104: Swift.UInt64, _ n105: Swift.UInt64, _ n106: Swift.UInt64, _ n107: Swift.UInt64, _ n108: Swift.UInt64, _ n109: Swift.UInt64, _ n110: Swift.UInt64, _ n111: Swift.UInt64, _ n112: Swift.UInt64, _ n113: Swift.UInt64, _ n114: Swift.UInt64, _ n115: Swift.UInt64, _ n116: Swift.UInt64, _ n117: Swift.UInt64, _ n118: Swift.UInt64, _ n119: Swift.UInt64, _ n120: Swift.UInt64, _ n121: Swift.UInt64, _ n122: Swift.UInt64, _ n123: Swift.UInt64) -> Swift.UInt64 @inlinable public func jniOne() -> Swift.UInt32 @inlinable public func polarPoint(_ distance: Swift.UInt32) -> PolarPoint? +@inlinable public func macrosStreamed(_ streams: MacrosStreams, _ errno: Swift.UInt8) -> Swift.UInt32 @inlinable public func clashAny(_ typeUrl: Swift.String) -> ClashAny @inlinable public func clashCandidate(_ at: Swift.UInt8) -> ClashCandidate @inlinable public func clashIgnore(_ arg0: Swift.UInt8, _ arg1: Swift.UInt8, _ arg2: Swift.UInt8) -> Swift.UInt8 diff --git a/ffi/surface/api/web.d.ts b/ffi/surface/api/web.d.ts index efdca037a..fe741b111 100644 --- a/ffi/surface/api/web.d.ts +++ b/ffi/surface/api/web.d.ts @@ -809,6 +809,16 @@ export declare function c(self: LongArray): rt.u64; export declare function also(self: LongArray, f: (a0: rt.u64) => void): void; export { new$ as new }; +// MacrosStreams.ts +export type MacrosStreams = { + stdin: number; + stdout: number; + stderr: number; + errno: number; +}; +export declare function debug(self: MacrosStreams): string; +export declare function eq(a: MacrosStreams, b: MacrosStreams): boolean; + // Mark.ts import * as rt from "./rt.ts"; export type Mark = rt.Handle<"Mark">; @@ -1734,6 +1744,7 @@ import type { LimitsDuration } from "./LimitsDuration.ts"; import type { Local } from "./Local.ts"; import type { LogCount } from "./LogCount.ts"; import type { LongArray } from "./LongArray.ts"; +import type { MacrosStreams } from "./MacrosStreams.ts"; import type { Mark } from "./Mark.ts"; import type { Measure } from "./Measure.ts"; import type { Moment } from "./Moment.ts"; @@ -2212,6 +2223,7 @@ export declare function w_clash_Escaped(p: number, v: ClashEscaped): void; export declare function w_clash_Span(p: number, v: ClashSpan): void; export declare function w_clash_TONE(p: number, v: ClashTone_): void; export declare function w_clash_Tone(p: number, v: ClashTone): void; +export declare function w_macros_Streams(p: number, v: MacrosStreams): void; export declare function w_option_Level(p: number, v: Level | undefined): void; export declare function w_option_Point(p: number, v: Point | undefined): void; export declare function w_option_Point_2(p: number, v: Point | undefined): void; @@ -2351,6 +2363,7 @@ import type { LimitsBytes } from "./LimitsBytes.ts"; import type { LimitsDuration } from "./LimitsDuration.ts"; import type { Local } from "./Local.ts"; import type { Log } from "./Log.ts"; +import type { MacrosStreams } from "./MacrosStreams.ts"; import type { Mark } from "./Mark.ts"; import type { Moment } from "./Moment.ts"; import type { Name } from "./Name.ts"; @@ -2707,6 +2720,9 @@ export declare function boothCount(booth: Booth): rt.u64; export declare function page(): Page; export declare function beats(beat: Beat): number; export declare function same(a: rt.f64, b: rt.f64): number; +export declare function errno(): number; +export declare function assert(holds: boolean): boolean; +export declare function offsetof(field: number): number; export declare function returnValues(point: rt.Place, fail: boolean): rt.Result<[string, [number, number, number, rt.u64] | undefined, Uint8Array[]], Error_>; export declare function returnMoved(counter: Counter, fail: boolean): rt.Result; export declare function nonZeros(): NonZeros; @@ -2737,6 +2753,7 @@ export declare function crowded(reading: Reading, a: Stamp, b: Stamp, n0: rt.u64 export declare function crammed(a: Moment, b: Moment, n0: rt.u64, n1: rt.u64, n2: rt.u64, n3: rt.u64, n4: rt.u64, n5: rt.u64, n6: rt.u64, n7: rt.u64, n8: rt.u64, n9: rt.u64, n10: rt.u64, n11: rt.u64, n12: rt.u64, n13: rt.u64, n14: rt.u64, n15: rt.u64, n16: rt.u64, n17: rt.u64, n18: rt.u64, n19: rt.u64, n20: rt.u64, n21: rt.u64, n22: rt.u64, n23: rt.u64, n24: rt.u64, n25: rt.u64, n26: rt.u64, n27: rt.u64, n28: rt.u64, n29: rt.u64, n30: rt.u64, n31: rt.u64, n32: rt.u64, n33: rt.u64, n34: rt.u64, n35: rt.u64, n36: rt.u64, n37: rt.u64, n38: rt.u64, n39: rt.u64, n40: rt.u64, n41: rt.u64, n42: rt.u64, n43: rt.u64, n44: rt.u64, n45: rt.u64, n46: rt.u64, n47: rt.u64, n48: rt.u64, n49: rt.u64, n50: rt.u64, n51: rt.u64, n52: rt.u64, n53: rt.u64, n54: rt.u64, n55: rt.u64, n56: rt.u64, n57: rt.u64, n58: rt.u64, n59: rt.u64, n60: rt.u64, n61: rt.u64, n62: rt.u64, n63: rt.u64, n64: rt.u64, n65: rt.u64, n66: rt.u64, n67: rt.u64, n68: rt.u64, n69: rt.u64, n70: rt.u64, n71: rt.u64, n72: rt.u64, n73: rt.u64, n74: rt.u64, n75: rt.u64, n76: rt.u64, n77: rt.u64, n78: rt.u64, n79: rt.u64, n80: rt.u64, n81: rt.u64, n82: rt.u64, n83: rt.u64, n84: rt.u64, n85: rt.u64, n86: rt.u64, n87: rt.u64, n88: rt.u64, n89: rt.u64, n90: rt.u64, n91: rt.u64, n92: rt.u64, n93: rt.u64, n94: rt.u64, n95: rt.u64, n96: rt.u64, n97: rt.u64, n98: rt.u64, n99: rt.u64, n100: rt.u64, n101: rt.u64, n102: rt.u64, n103: rt.u64, n104: rt.u64, n105: rt.u64, n106: rt.u64, n107: rt.u64, n108: rt.u64, n109: rt.u64, n110: rt.u64, n111: rt.u64, n112: rt.u64, n113: rt.u64, n114: rt.u64, n115: rt.u64, n116: rt.u64, n117: rt.u64, n118: rt.u64, n119: rt.u64, n120: rt.u64, n121: rt.u64, n122: rt.u64, n123: rt.u64): rt.u64; export declare function jniOne(): number; export declare function polarPoint(distance: number): PolarPoint | undefined; +export declare function macrosStreamed(streams: MacrosStreams, errno: number): number; export declare function clashAny(typeUrl: string): ClashAny; export declare function clashCandidate(at: number): ClashCandidate; export declare function clashIgnore(arg0: number, arg1: number, arg2: number): number; diff --git a/ffi/tests/api.c b/ffi/tests/api.c index 95a56e202..d9ec65557 100644 --- a/ffi/tests/api.c +++ b/ffi/tests/api.c @@ -7,9 +7,12 @@ * * With an argument, it instead breaks one contract of the ABI, which must abort. */ +#include +#include #include #include #include +#include #include #include #include @@ -844,6 +847,13 @@ static api_buf unspelled(void) { /* What the transcript's output does not show: each check of the ABI's contract beyond it. */ static void checks(void) { + /* A field and a parameter named as `errno`, a macro of , which take a trailing `_` + * rather than expand. */ + api_macros_Streams streams = {1, 2, 3, 4}; + if (streams.errno_ != 4 || api_macros_streamed(streams, 5) != 15 || api_errno() != 7) { + tr_fail("names of C library macros"); + } + /* A name takes a copy: the caller's buffer is its own again. */ api_Name *name = api_Name_owned(str("a")); char text[] = "c"; diff --git a/ffi/tests/api.cpp b/ffi/tests/api.cpp index 42e6450a0..dfeeb422c 100644 --- a/ffi/tests/api.cpp +++ b/ffi/tests/api.cpp @@ -8,9 +8,12 @@ #include #include +#include +#include #include #include #include +#include #include #include #include @@ -530,6 +533,14 @@ int check(bool ok, const char *what) { // What the transcript's script says only in Rust: C++'s own copies, hashes, ranges, and // operators, each checked by an assertion. int checks() { + // Names of the macros ``, ``, and `` define, and a field and a + // parameter of `errno`'s name, which each take a trailing `_` rather than expand. + { + api::macros_Streams streams{1, 2, 3, 4}; + check(api::errno_() == 7 && api::assert_(true) && api::offsetof_(3) == 3 && streams.errno_ == 4 && + api::macros_streamed(streams, 5) == 15, + "names of C library macros"); + } // Fields named as an `operator==`'s argument might be. { api::Shadowed one{{1}, 2, 3}; diff --git a/ffi/tests/api.kt b/ffi/tests/api.kt index d9e081d3b..2335e1af4 100644 --- a/ffi/tests/api.kt +++ b/ffi/tests/api.kt @@ -1375,6 +1375,8 @@ fun clash() { val out = Mut(0u) check(Clash.Int(4).describe("t", 3u, Shape.SQUARE, out) == "t Int(4) 3 Square" && out.value == 6u, "clash describe") check(Handle.new(5u).use { it.count() } == 5u && runBlocking { Handle.later(6u) }.use { it.count() } == 6u, "an object named as a former runtime class") + // Names of C library macros, which C and C++ keep apart. + check(errno() == 7 && assert(true) && offsetof(3u) == 3.toUByte() && MacrosStreams(1u, 2u, 3u, 4u).errno == 4.toUByte() && macrosStreamed(MacrosStreams(1u, 2u, 3u, 4u), 5u) == 15u, "names of C library macros") } fun returns() { diff --git a/ffi/tests/fixtures.rs b/ffi/tests/fixtures.rs index e6c4b125e..d62f68329 100644 --- a/ffi/tests/fixtures.rs +++ b/ffi/tests/fixtures.rs @@ -4989,6 +4989,92 @@ fn plain() { .env("RUSTFLAGS", "-D warnings")); } +/// A facade that reaches `bytes`, whose `Take` its signature names though it re-exports +/// nothing of the crate, builds with the one dependency on it the glue's own `Bytes` shares: +/// cargo refuses two under different names. +#[test] +fn reaches_bytes() { + let package = package( + "reaches_bytes", + &[ + ( + "Cargo.toml", + "[package]\nname = \"reaches_bytes\"\nversion = \"0.0.0\"\nedition = \"2024\"\n\n\ + [dependencies]\nbytes = \"1\"\n\n[workspace]\n", + ), + ( + "src/lib.rs", + "pub fn limited(bytes: bytes::Bytes) -> bytes::buf::Take {\n\tbytes::Buf::take(bytes, 2)\n}\n", + ), + ], + ); + export_and_build(&package, &["--offline"]); +} + +/// A facade whose `bytes` is a `path` dependency that only the host's API reaches: the glue +/// declares `bytes` once, from the facade's source, for every target, never also as the +/// registry's, which cargo refuses as one name from two sources. +#[test] +fn reaches_bytes_on_the_host() { + // The registry's `bytes`, copied beside the facade to be its `path` dependency. + let source = package("reaches_bytes_source", &[]); + write_all( + &source, + &[( + "Cargo.toml", + "[package]\nname = \"reaches_bytes_source\"\nversion = \"0.0.0\"\nedition = \"2024\"\n\n\ + [dependencies]\nbytes = \"1\"\n\n[workspace]\n", + )], + ); + run(cargo() + .args(["fetch", "--quiet", "--manifest-path"]) + .arg(source.join("Cargo.toml"))); + let metadata = run(cargo() + .args(["metadata", "--format-version", "1", "--offline", "--manifest-path"]) + .arg(source.join("Cargo.toml"))); + let metadata: serde_json::Value = serde_json::from_slice(&metadata.stdout).unwrap(); + let registry = (metadata["packages"].as_array().unwrap().iter()) + .find(|p| p["name"] == "bytes") + .map(|p| { + Path::new(p["manifest_path"].as_str().unwrap()) + .parent() + .unwrap() + .to_path_buf() + }) + .unwrap(); + let package = package( + "reaches_bytes_host", + &[ + ( + "Cargo.toml", + "[package]\nname = \"reaches_bytes_host\"\nversion = \"0.0.0\"\nedition = \"2024\"\n\n\ + [dependencies]\nbytes = { path = \"bytes\" }\n\n[workspace]\nexclude = [\"bytes\"]\n", + ), + ( + "src/lib.rs", + "#[cfg(not(target_arch = \"wasm32\"))]\npub fn limited(bytes: bytes::Bytes) -> bytes::buf::Take {\n\tbytes::Buf::take(bytes, 2)\n}\n\n\ + pub fn both() -> u32 {\n\t1\n}\n", + ), + ], + ); + step::mirror(®istry, &package.join("bytes")); + let out = package.join("out"); + run(Command::new(env!("CARGO_BIN_EXE_rust2-ffi")) + .arg("--manifest-path") + .arg(package.join("Cargo.toml")) + .arg("--out") + .arg(&out) + .args(["--target", WASM, "--target", host(), "--", "--offline"]) + .env("CARGO_TARGET_DIR", package.join("build"))); + let manifest = std::fs::read_to_string(out.join("Cargo.toml")).unwrap(); + let declared: Vec<&str> = manifest.lines().filter(|l| l.starts_with("bytes = ")).collect(); + assert!( + declared.len() == 1 && declared[0].contains("path"), + "bytes is declared once, from the facade's source:\n{manifest}" + ); + build_offline(&out, &package.join("glue")); +} + /// A dependency the facade re-exports from, patched in for a registry dependency, is /// patched into the glue's build too, though the dependency goes by its library's crate /// name. So is a dependency of no platform's, which cargo resolves all the same. diff --git a/ffi/tests/fixtures/corpus.rs b/ffi/tests/fixtures/corpus.rs index d11b20359..d08f22ecd 100644 --- a/ffi/tests/fixtures/corpus.rs +++ b/ffi/tests/fixtures/corpus.rs @@ -21,8 +21,6 @@ use super::{cargo, manifest_dir, run, scratch, step}; /// fixes it, or else why none can. They are not run; the quest's PR deletes its entry. const KNOWN: &[(&str, &str)] = &[ ("anyhow", "/quest/m1/ffi-apart.md"), - ("axum", "/quest/m1/ffi-corpus-bugs.md"), - ("bytes", "/quest/m1/ffi-corpus-bugs.md"), ( "core-foundation", "macOS's CoreFoundation: calls a platform library this host lacks, so no binding loads", @@ -31,9 +29,7 @@ const KNOWN: &[(&str, &str)] = &[ ("darling", "/quest/m1/ffi-apart.md"), ("der", "/quest/m1/ffi-apart.md"), ("env_logger", "/quest/m1/ffi-apart.md"), - ("errno", "/quest/m1/ffi-corpus-bugs.md"), ("hermit-abi", "/quest/m1/ffi-apart.md"), - ("hyper", "/quest/m1/ffi-corpus-bugs.md"), ("icu_locale_core", "/quest/m1/ffi-apart.md"), ("itertools", "/quest/m1/ffi-apart.md"), ("js-sys", "/quest/m1/ffi-inference.md"), @@ -182,6 +178,82 @@ struct Passed { refused: usize, } +/// A crate whose items take the root names of what the runtimes of the bindings declare, +/// `bytes`'s own `Bytes` among them, and the lowercase macros of the C library's headers, +/// binds in every language: each corpus crate that failed in one did so as these do, though +/// a refusal now keeps most of them from reaching a binding. +#[test] +fn runtime_names() { + let package = super::package( + "runtime_names", + &[( + "src/lib.rs", + "\ +pub struct Bytes { + data: Vec, +} + +impl Bytes { + pub fn counting(len: u8) -> Self { + Self { data: (0..len).collect() } + } + + pub fn split_off(&mut self, at: usize) -> Self { + Self { data: self.data.split_off(at) } + } +} + +pub struct Waker { + pub woken: bool, +} + +pub struct Mut { + pub by: u8, +} + +pub struct Bound { + pub limit: u8, +} + +pub fn errno() -> i32 { + 7 +} + +pub fn assert(holds: bool) -> bool { + holds +} + +pub fn offsetof(field: u8) -> u8 { + field +} + +pub struct Streams { + pub stdin: u8, + pub stdout: u8, + pub stderr: u8, +} +", + )], + ); + let out = package.join("out"); + let output = super::output( + Command::new(env!("CARGO_BIN_EXE_rust2-ffi")) + .arg("--manifest-path") + .arg(package.join("Cargo.toml")) + .arg("--out") + .arg(&out) + .env("CARGO_TARGET_DIR", package.join("build")), + ); + assert!( + output.status.success(), + "the export failed:\n{}", + String::from_utf8_lossy(&output.stderr) + ); + let built = bind("runtime_names", &out).unwrap_or_else(|(stage, output)| panic!("{stage}: {}", trimmed(&output))); + languages("runtime_names", &out, &package, &built) + .unwrap_or_else(|(stage, output)| panic!("{stage}: {}", trimmed(&output))); +} + /// Census and export every crate of the corpus, or of `CORPUS_SHARD`'s `i/n`, the `i`th of /// `n` slices, or those `CORPUS_CRATES` names, and build each binding, writing the report /// to `target/tmp/corpus/report.md`, or a shard's to `target/tmp/corpus--of-/report.md`. diff --git a/quest/m1/ffi-corpus-bugs.md b/quest/m1/ffi-corpus-bugs.md deleted file mode 100644 index a64d23515..000000000 --- a/quest/m1/ffi-corpus-bugs.md +++ /dev/null @@ -1,28 +0,0 @@ -# [S] Fix the corpus's binding bugs - -## Goal - -errno, bytes, axum, and hyper bind and leave `KNOWN` in `ffi/tests/fixtures/corpus.rs`. - -## Plan - -Kept by the maintainer on 2026-11-19, in the pick of [#878](https://github.com/kixel-ai/rust2/pull/878). - -Found by [the corpus](/ffi/tests/fixtures/corpus.rs) on 2026-11-19: - -- errno: C++ lifts `__errno_location`'s result as an `Errno` where its declaration returns - a function pointer. -- bytes: Kotlin's `Bytes.splitOff` reads `this.handle`, which an object of `Bytes`'s - shape lacks. -- axum and hyper: the glue crate depends on `bytes` twice, at the facade's version and at - another, which cargo refuses. - -Since [no config](https://github.com/kixel-ai/rust2/pull/903), the corpus exports only a -crate whose census refuses nothing, as a refusal fails the export, so a crate here that -refuses an item no longer reaches its bindings: prove each fix on its reduction in the api -fixture, and through the corpus only where the crate's census is clean. - -Recommended: reduce each to a case in the api fixture first, since each is a generator bug -the fixtures do not reach yet. - -Public API: none.