//! Shared name constants for strings that cross the component/core
//! boundary where two sides must agree on an exact literal.
//!
//! **Not in scope here:** anything derived from the tier-1 WIT file.
//! That includes:
//!
//! - The middleware's hook function names (`before-call`, `after-call`,
//!   `should-block-call`) — available as `TIER1_BEFORE_FNS` /
//!   `TIER1_AFTER_FNS` / `TIER1_BLOCKING_FNS` in [`crate::contract`].
//! - Their underscored env-slot counterparts (`before_call`, etc.) —
//!   available as `TIER1_BEFORE_ENV_SLOTS` / `TIER1_AFTER_ENV_SLOTS` /
//!   `TIER1_BLOCKING_ENV_SLOTS` in [`crate::contract`], generated by
//!   `build.rs` from the same WIT source with hyphens replaced by
//!   underscores.

pub(crate) const ENV_INSTANCE: &str = "env";

pub(crate) const ENV_MEMORY: &str = "mem";
pub(crate) const ENV_REALLOC: &str = "realloc";

pub(crate) const ENV_WAITABLE_NEW: &str = "waitable_new";
pub(crate) const ENV_WAITABLE_JOIN: &str = "waitable_join";
pub(crate) const ENV_WAITABLE_WAIT: &str = "waitable_wait";
pub(crate) const ENV_WAITABLE_DROP: &str = "waitable_drop";
pub(crate) const ENV_SUBTASK_DROP: &str = "subtask_drop";

/// Per-function handler import/export name. `i` is the index of the
/// function in `funcs` (parallel to [`super::func::AdapterFunc`]).
pub(crate) fn env_handler_fn(i: usize) -> String {
    format!("handler_f{i}")
}

/// Per-function `task.return` import/export name. `i` matches
/// [`env_handler_fn`].
pub(crate) fn env_task_return_fn(i: usize) -> String {
    format!("task_return_f{i}")
}
