Skip to content

Engine → Bindings

marshal.h

Marshalling rules of the C ABI: everything crosses blittable or as (pointer, length). Math records are memcpy-compatible with the core types (the static_asserts below pin that, including the x, y, z, w storage of math::quat); entities travel as the packed u64 of ecs::entity; uuids as two u64 halves; strings in as UTF-8 pointer + byte length (never terminated); strings and arrays out follow the needed-length / count protocol.

Structs

File Description
marshal::structural_guard Decides where a structural request goes: straight to the world while it is unlocked, into script_runtime::deferred_commands() while a DOD query scope holds the lock. Constructed per structural entry; runtime may be null (then a locked request has no buffer and reports STRUCTURE_LOCKED through can_defer()).

Functions

Public

marshal::from_entity

[[nodiscard]] constexpr uint64_t from_entity(ecs::entity value) noexcept;

marshal::from_mat4

[[nodiscard]] inline conjure_mat4 from_mat4(const math::mat4 &value) noexcept;

marshal::from_quat

[[nodiscard]] inline conjure_quat_xyzw from_quat(const math::quat &value) noexcept;

marshal::from_transform

[[nodiscard]] inline conjure_transform from_transform(const math::transform &value) noexcept;

marshal::from_uuid

[[nodiscard]] constexpr conjure_uuid from_uuid(const core::uuid &value) noexcept;

marshal::from_vec2

[[nodiscard]] inline conjure_vec2 from_vec2(const math::vec2 &value) noexcept;

marshal::from_vec3

[[nodiscard]] inline conjure_vec3 from_vec3(const math::vec3 &value) noexcept;

marshal::from_vec4

[[nodiscard]] inline conjure_vec4 from_vec4(const math::vec4 &value) noexcept;

marshal::quat_storage_is_xyzw

[[nodiscard]] CONJURE_API bool quat_storage_is_xyzw() noexcept;

True when math::quat stores its components x, y, z, w in memory (glm 1.0.1 without GLM_FORCE_QUAT_DATA_WXYZ), which is what makes to_transform / from_transform a memcpy. glm's quaternion is a union of anonymous structs on MSVC, so the check is a runtime byte comparison rather than an offsetof.

marshal::read_utf8

[[nodiscard]] CONJURE_API core::result<std::string_view> read_utf8(const char *utf8, int32_t length) noexcept;

A UTF-8 (pointer, byte length) argument as a view. INVALID_ARGUMENT (bindings category) for a null pointer with a positive length or a negative length; (nullptr, 0) and (anything, 0) are "".

marshal::rgba_to_color

[[nodiscard]] constexpr math::vec4 rgba_to_color(uint32_t rgba) noexcept;

0xRRGGBBAA to a linear float colour with channels in [0, 1].

marshal::to_entity

[[nodiscard]] constexpr ecs::entity to_entity(uint64_t packed) noexcept;

marshal::to_mat4

[[nodiscard]] inline math::mat4 to_mat4(const conjure_mat4 &value) noexcept;

marshal::to_quat

[[nodiscard]] inline math::quat to_quat(const conjure_quat_xyzw &value) noexcept;

By-name conversion: math::quat is constructed (w, x, y, z) but stored x, y, z, w.

marshal::to_transform

[[nodiscard]] inline math::transform to_transform(const conjure_transform &value) noexcept;

marshal::to_uuid

[[nodiscard]] constexpr core::uuid to_uuid(const conjure_uuid &value) noexcept;

marshal::to_vec2

[[nodiscard]] inline math::vec2 to_vec2(const conjure_vec2 &value) noexcept;

marshal::to_vec3

[[nodiscard]] inline math::vec3 to_vec3(const conjure_vec3 &value) noexcept;

marshal::to_vec4

[[nodiscard]] inline math::vec4 to_vec4(const conjure_vec4 &value) noexcept;

marshal::write_entities

[[nodiscard]] CONJURE_API int32_t write_entities( std::span<const ecs::entity> entities, uint64_t *out, int32_t capacity ) noexcept;

The count protocol of entity arrays: writes min(entities.size(), capacity) packed ids and returns the full count; capacity 0 (or a null buffer) is a count query.

marshal::write_utf8

[[nodiscard]] CONJURE_API int32_t write_utf8(std::string_view text, char *utf8, int32_t capacity) noexcept;

The needed-length protocol of string outputs: writes min(text.size(), capacity) bytes into utf8 (no terminator) and returns the full length; capacity 0 (or a null buffer) is a length query, a negative capacity writes nothing.