|
DETLEF C SDK
Native embedding and package authoring
|
| DetlefStatus detlef_access_error | ( | DetlefAccess * | a, |
| DetlefText * | out, | ||
| DetlefSpan * | span, | ||
| DetlefBool * | has_span | ||
| ) |
Copy the last diagnostic associated with this access, including an optional source span. Reading it does not clear the error.
| a | Borrowed callback access. Must not be freed, saved, or used outside its current callback. | |
| [out] | out | Receives owned UTF-8 text without a trailing NUL. Must be freed once with detlef_text_free(). |
| [out] | span | Receives a half-open source range in UTF-8 byte offsets. No cleanup is required. |
| [out] | has_span | Receives one when a diagnostic includes a span, otherwise zero. No cleanup is required. |
| DetlefStatus detlef_argument_boolean | ( | DetlefAccess * | a, |
| size_t | index, | ||
| DetlefBool * | out | ||
| ) |
Read an argument as a boolean, evaluating it in a Control. Non-boolean values are rejected.
| a | Borrowed callback access. Must not be freed, saved, or used outside its current callback. | |
| index | Zero-based argument index. | |
| [out] | out | Receives DETLEF_FALSE or DETLEF_TRUE. |
| DetlefStatus detlef_argument_count | ( | DetlefAccess * | a, |
| size_t * | out | ||
| ) |
Read the number of arguments supplied to the current callable. A setup access has no callable arguments.
| a | Borrowed callback access. Must not be freed, saved, or used outside its current callback. | |
| [out] | out | Receives the number of arguments in the current callback. |
| DetlefStatus detlef_argument_evaluate | ( | DetlefAccess * | a, |
| size_t | index, | ||
| DetlefHandle * | out | ||
| ) |
Evaluate a Control argument by zero-based index. Repeated calls repeat evaluation and its side effects. Functions return their already evaluated argument.
| a | Borrowed callback access. Must not be freed, saved, or used outside its current callback. | |
| index | Zero-based argument index. | |
| [out] | out | On success, receives an owned evaluation handle for the argument, including descriptors or void. Release with detlef_handle_release() unless transferred as a callback result. |
| DetlefStatus detlef_argument_expression | ( | DetlefAccess * | a, |
| size_t | index, | ||
| DetlefHandle * | out | ||
| ) |
Obtain the unevaluated expression for a Control argument. Eager Function arguments do not have expressions.
| a | Borrowed callback access. Must not be freed, saved, or used outside its current callback. | |
| index | Zero-based argument index. | |
| [out] | out | On success, receives an owned argument expression handle. Release with detlef_handle_release(). |
| DetlefStatus detlef_argument_identifier | ( | DetlefAccess * | a, |
| size_t | index, | ||
| DetlefText * | out | ||
| ) |
Copy the identifier in a Control argument without evaluating it. Non-identifier expressions are rejected.
| a | Borrowed callback access. Must not be freed, saved, or used outside its current callback. | |
| index | Zero-based argument index. | |
| [out] | out | Receives owned UTF-8 text without a trailing NUL. Must be freed once with detlef_text_free(). |
| DetlefStatus detlef_argument_span | ( | DetlefAccess * | a, |
| size_t | index, | ||
| DetlefSpan * | out | ||
| ) |
Read a Control argument's source span in UTF-8 byte offsets.
| a | Borrowed callback access. Must not be freed, saved, or used outside its current callback. | |
| index | Zero-based argument index. | |
| [out] | out | Receives the argument's half-open source range in UTF-8 byte offsets. |
| DetlefStatus detlef_argument_value | ( | DetlefAccess * | a, |
| size_t | index, | ||
| DetlefHandle * | out | ||
| ) |
Obtain a runtime value from an argument, evaluating it in a Control. Void and descriptor results are rejected.
| a | Borrowed callback access. Must not be freed, saved, or used outside its current callback. | |
| index | Zero-based argument index. | |
| [out] | out | On success, receives an owned runtime value handle for the argument. Release with detlef_handle_release() unless transferred as a callback result. |
| DetlefStatus detlef_call_span | ( | DetlefAccess * | a, |
| DetlefSpan * | out | ||
| ) |
Read the current Control call's source span. The operation requires an expression- backed callback.
| a | Borrowed callback access. Must not be freed, saved, or used outside its current callback. | |
| [out] | out | Receives the current call's half-open source range in UTF-8 byte offsets. |
| DetlefStatus detlef_callback_error | ( | DetlefAccess * | a, |
| DetlefSlice | message, | ||
| DetlefSpan | span, | ||
| DetlefBool | has_span | ||
| ) |
Set a callback diagnostic and return DETLEF_ERROR. The message is copied. Set has_span to one to attach a source range.
| a | Borrowed callback access. Must not be freed, saved, or used outside its current callback. |
| message | Borrowed UTF-8 diagnostic text, copied during this call. |
| span | Half-open source range in UTF-8 byte offsets. |
| has_span | One attaches a source span; zero omits it. |
| DetlefStatus detlef_register_binding | ( | DetlefAccess * | a, |
| DetlefSlice | input, | ||
| DetlefHandle | handle | ||
| ) |
Register a named value binding by copying its value. The supplied handle remains owned by its caller; this is separate from declaring a mutable variable.
| a | Borrowed callback access. Must not be freed, saved, or used outside its current callback. |
| input | Borrowed UTF-8 name, without a trailing NUL requirement. Storage may be released after the call. |
| handle | Borrowed runtime value handle to bind. Not consumed. |
| DetlefStatus detlef_register_control | ( | DetlefAccess * | a, |
| DetlefSlice | input, | ||
| DetlefCallback | callback, | ||
| void * | data | ||
| ) |
Register a lazy Control with full context access. Callback code and data must remain valid while the registration can be invoked.
| a | Borrowed callback access. Must not be freed, saved, or used outside its current callback. |
| input | Borrowed UTF-8 name, without a trailing NUL requirement. Storage may be released after the call. |
| callback | Synchronous callback. Its code and associated data must remain valid while registered; DETLEF does not free them. |
| data | Host-owned callback data. Must remain valid while its callback can run; DETLEF never frees it. |
| DetlefStatus detlef_register_function | ( | DetlefAccess * | a, |
| DetlefSlice | input, | ||
| const DetlefNamed * | params, | ||
| size_t | count, | ||
| const DetlefNamed * | vararg, | ||
| DetlefFunctionCallback | callback, | ||
| void * | data | ||
| ) |
Register an eager native Function using resolved parameter types and an optional variadic parameter. Callback code and data must remain valid while the registration can be invoked.
| a | Borrowed callback access. Must not be freed, saved, or used outside its current callback. |
| input | Borrowed UTF-8 name, without a trailing NUL requirement. Storage may be released after the call. |
| params | Borrowed parameter names paired with resolved type descriptors. Names are copied; handles are not consumed. |
| count | Number of entries in the supplied array. |
| vararg | Optional borrowed variadic parameter with a resolved element type descriptor; NULL means no variadic parameter. |
| callback | Synchronous callback. Its code and associated data must remain valid while registered; DETLEF does not free them. |
| data | Host-owned callback data. Must remain valid while its callback can run; DETLEF never frees it. |
| DetlefStatus detlef_register_script_function | ( | DetlefAccess * | a, |
| DetlefSlice | input, | ||
| const DetlefNamed * | params, | ||
| size_t | count, | ||
| const DetlefNamed * | vararg, | ||
| DetlefHandle | body, | ||
| DetlefHandle | env | ||
| ) |
Register a script Function using resolved parameter types and a body expression. A zero environment handle captures the current environment.
| a | Borrowed callback access. Must not be freed, saved, or used outside its current callback. |
| input | Borrowed UTF-8 name, without a trailing NUL requirement. Storage may be released after the call. |
| params | Borrowed parameter names paired with resolved type descriptors. Names are copied; handles are not consumed. |
| count | Number of entries in the supplied array. |
| vararg | Optional borrowed variadic parameter with a resolved element type descriptor; NULL means no variadic parameter. |
| body | Borrowed body expression handle, copied into the registration. Not consumed. |
| env | Borrowed captured-environment handle; zero captures the current environment. Not consumed. |
| DetlefStatus detlef_stdlib_install | ( | DetlefAccess * | a, |
| DetlefOutput | output_callback, | ||
| void * | output_data, | ||
| DetlefLineInput | input_callback, | ||
| void * | input_data | ||
| ) |
Install the standard library with synchronous output and optional input callbacks. Output bytes are borrowed; input bytes remain host-owned and are copied immediately after the input callback returns. A null input callback means EOF.
| a | Borrowed callback access. Must not be freed, saved, or used outside its current callback. |
| output_callback | Synchronous callback. Its code and associated data must remain valid while registered; DETLEF does not free them. |
| output_data | Host-owned callback data. Must remain valid while its callback can run; DETLEF never frees it. |
| input_callback | Synchronous callback. Its access and borrowed buffers must not escape the callback. Input may be NULL to provide EOF. |
| input_data | Host-owned callback data. Must remain valid while its callback can run; DETLEF never frees it. |