Liking cljdoc? Tell your friends :D

clj-zig.infer

Read a Zig pub fn prototype into data so a signatureless defnz can infer its boundary contract from the co-located source. prototype parses only the declaration, never the body: the parameter bindings and their Zig type strings, and the return type string. Mapping those strings to boundary type forms is a separate step. Pure.

Read a Zig `pub fn` prototype into data so a signatureless `defnz` can
infer its boundary contract from the co-located source. `prototype`
parses only the declaration, never the body: the parameter bindings and
their Zig type strings, and the return type string. Mapping those strings
to boundary type forms is a separate step. Pure.
raw docstring

infer-signatureclj

(infer-signature zig-text fn-name)

The boundary signature vector inferred from fn-name's prototype in zig-text: each parameter's binding and boundary type, then :ret and the return type. Throws :clj-zig/inferred-fn-not-found when the file declares no such pub fn, and :clj-zig/contract-policy-needed when the return is a slice or pointer, whose ownership or handle policy must be stated in an explicit signature.

The boundary signature vector inferred from `fn-name`'s prototype in
`zig-text`: each parameter's binding and boundary type, then `:ret` and
the return type. Throws `:clj-zig/inferred-fn-not-found` when the file
declares no such `pub fn`, and `:clj-zig/contract-policy-needed` when the
return is a slice or pointer, whose ownership or handle policy must be
stated in an explicit signature.
sourceraw docstring

prototypeclj

(prototype zig-text fn-name)

The prototype of pub fn <fn-name> in zig-text, or nil when the file declares no such function. Returns {:name <fn-name> :params [{:binding :zig-type}...] :ret <return-type-string>}, with type strings left verbatim for a later mapping step. Parses the declaration only.

The prototype of `pub fn <fn-name>` in `zig-text`, or nil when the file
declares no such function. Returns `{:name <fn-name> :params [{:binding
:zig-type}...] :ret <return-type-string>}`, with type strings left
verbatim for a later mapping step. Parses the declaration only.
sourceraw docstring

zig-type->boundaryclj

(zig-type->boundary type-str)
(zig-type->boundary type-str position)

The boundary type form for a Zig type string. The default reads a parameter, whose shape is fully determined by the type. A :return position yields ::policy-needed when the type is a slice or a pointer, because a returned []T or *T carries no ownership or handle policy in its type; that policy is a Clojure-side decision and needs an explicit signature.

The boundary type form for a Zig type string. The default reads a
parameter, whose shape is fully determined by the type. A `:return`
position yields `::policy-needed` when the type is a slice or a pointer,
because a returned `[]T` or `*T` carries no ownership or handle policy in
its type; that policy is a Clojure-side decision and needs an explicit
signature.
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close