DETLEF C SDK
Native embedding and package authoring
Loading...
Searching...
No Matches
Handles and Values

Functions

DetlefStatus detlef_handle_release (DetlefAccess *a, DetlefHandle handle)
 
DetlefStatus detlef_handle_clone (DetlefAccess *a, DetlefHandle handle, DetlefHandle *out)
 
DetlefStatus detlef_handle_kind (DetlefAccess *a, DetlefHandle handle, DetlefHandleKind *out)
 
DetlefStatus detlef_value_none (DetlefAccess *a, DetlefHandle *out)
 
DetlefStatus detlef_value_integer (DetlefAccess *a, int64_t value, DetlefHandle *out)
 
DetlefStatus detlef_value_float (DetlefAccess *a, double value, DetlefHandle *out)
 
DetlefStatus detlef_value_boolean (DetlefAccess *a, DetlefBool value, DetlefHandle *out)
 
DetlefStatus detlef_value_string (DetlefAccess *a, DetlefSlice input, DetlefHandle *out)
 
DetlefStatus detlef_value_get_integer (DetlefAccess *a, DetlefHandle handle, int64_t *out)
 
DetlefStatus detlef_value_get_float (DetlefAccess *a, DetlefHandle handle, double *out)
 
DetlefStatus detlef_value_get_boolean (DetlefAccess *a, DetlefHandle handle, DetlefBool *out)
 
DetlefStatus detlef_value_get_string (DetlefAccess *a, DetlefHandle handle, DetlefText *out)
 
DetlefStatus detlef_value_to_string (DetlefAccess *a, DetlefHandle handle, DetlefText *out)
 
DetlefStatus detlef_descriptor_create (DetlefAccess *a, DetlefDescriptorKind kind, DetlefSlice input, DetlefHandle type_handle, DetlefHandle *out)
 
DetlefStatus detlef_descriptor_info (DetlefAccess *a, DetlefHandle handle, DetlefText *name_out, DetlefHandle *type_out)
 
DetlefStatus detlef_execute (DetlefAccess *a, DetlefSlice source, DetlefHandle *out)
 

Detailed Description

Function Documentation

◆ detlef_descriptor_create()

DetlefStatus detlef_descriptor_create ( DetlefAccess *  a,
DetlefDescriptorKind  kind,
DetlefSlice  input,
DetlefHandle  type_handle,
DetlefHandle *  out 
)

Create a parameter, variadic-parameter, or field descriptor using its name and resolved type.

Parameters
aBorrowed callback access. Must not be freed, saved, or used outside its current callback.
kindDETLEF_DESCRIPTOR_PARAMETER, DETLEF_DESCRIPTOR_VARARG, or DETLEF_DESCRIPTOR_FIELD. The matching DETLEF_PARAMETER, DETLEF_VARARG, and DETLEF_FIELD handle-kind constants are also accepted.
inputBorrowed UTF-8 name, without a trailing NUL requirement. Storage may be released after the call.
type_handleBorrowed resolved type descriptor, for example from detlef_type_lookup(). Not consumed.
[out]outOn success, receives an owned descriptor handle of the requested kind. Release with detlef_handle_release() unless transferred as a callback result.
Returns
DETLEF_OK on success; otherwise a DetlefStatus error code.

◆ detlef_descriptor_info()

DetlefStatus detlef_descriptor_info ( DetlefAccess *  a,
DetlefHandle  handle,
DetlefText *  name_out,
DetlefHandle *  type_out 
)

Inspect a parameter, variadic-parameter, or field descriptor without consuming it.

Parameters
aBorrowed callback access. Must not be freed, saved, or used outside its current callback.
handleBorrowed parameter, variadic-parameter, or field descriptor handle. Not consumed.
[out]name_outReceives owned UTF-8 text without a trailing NUL. Must be freed once with detlef_text_free().
[out]type_outOn success, receives an owned resolved type descriptor for the named descriptor. Release with detlef_handle_release() unless transferred as a callback result.
Returns
DETLEF_OK on success; otherwise a DetlefStatus error code.

◆ detlef_execute()

DetlefStatus detlef_execute ( DetlefAccess *  a,
DetlefSlice  source,
DetlefHandle *  out 
)

Parse and execute source expressions in order and return the last evaluation. Earlier side effects remain if a later expression fails.

Parameters
aBorrowed callback access. Must not be freed, saved, or used outside its current callback.
sourceBorrowed UTF-8 source bytes. Storage may be released after the call.
[out]outOn success, receives an owned evaluation handle for the last expression, including descriptors or void. Release with detlef_handle_release() unless transferred as a callback result.
Returns
DETLEF_OK on success; otherwise a DetlefStatus error code.

◆ detlef_handle_clone()

DetlefStatus detlef_handle_clone ( DetlefAccess *  a,
DetlefHandle  handle,
DetlefHandle *  out 
)

Create a separately owned handle to the same value or descriptor. Objects remain shared; no deep copy is made.

Parameters
aBorrowed callback access. Must not be freed, saved, or used outside its current callback.
handleBorrowed handle to clone; zero produces a zero output. Not consumed.
[out]outOn success, receives an owned handle to the same item, or zero when the input is zero. Release with detlef_handle_release().
Returns
DETLEF_OK on success; otherwise a DetlefStatus error code.

◆ detlef_handle_kind()

DetlefStatus detlef_handle_kind ( DetlefAccess *  a,
DetlefHandle  handle,
DetlefHandleKind *  out 
)

Read the handle category, such as DETLEF_INTEGER, DETLEF_OBJECT, or DETLEF_TYPE. Zero has kind DETLEF_VOID.

Parameters
aBorrowed callback access. Must not be freed, saved, or used outside its current callback.
handleBorrowed handle to inspect; zero reports DETLEF_VOID. Not consumed.
[out]outReceives the DetlefHandleKind constant for the handle.
Returns
DETLEF_OK on success; otherwise a DetlefStatus error code.

◆ detlef_handle_release()

DetlefStatus detlef_handle_release ( DetlefAccess *  a,
DetlefHandle  handle 
)

Release one owned handle. The handle must not be used or released again; zero is a no-op.

Parameters
aBorrowed callback access. Must not be freed, saved, or used outside its current callback.
handleOwned handle to release. Must not be used afterwards; zero has no effect.
Returns
DETLEF_OK on success; otherwise a DetlefStatus error code.

◆ detlef_value_boolean()

DetlefStatus detlef_value_boolean ( DetlefAccess *  a,
DetlefBool  value,
DetlefHandle *  out 
)

Create a boolean value from DETLEF_FALSE (0) or DETLEF_TRUE (1). Other inputs are rejected.

Parameters
aBorrowed callback access. Must not be freed, saved, or used outside its current callback.
valueDETLEF_FALSE (0) or DETLEF_TRUE (1). Other values are rejected.
[out]outOn success, receives an owned boolean value handle. Release with detlef_handle_release() unless transferred as a callback result.
Returns
DETLEF_OK on success; otherwise a DetlefStatus error code.

◆ detlef_value_float()

DetlefStatus detlef_value_float ( DetlefAccess *  a,
double  value,
DetlefHandle *  out 
)

Create a floating-point value from a C double.

Parameters
aBorrowed callback access. Must not be freed, saved, or used outside its current callback.
valueFloating-point number to store.
[out]outOn success, receives an owned float value handle. Release with detlef_handle_release() unless transferred as a callback result.
Returns
DETLEF_OK on success; otherwise a DetlefStatus error code.

◆ detlef_value_get_boolean()

DetlefStatus detlef_value_get_boolean ( DetlefAccess *  a,
DetlefHandle  handle,
DetlefBool *  out 
)

Read a boolean as zero or one. Other value types are rejected.

Parameters
aBorrowed callback access. Must not be freed, saved, or used outside its current callback.
handleBorrowed boolean value handle. Not consumed.
[out]outReceives DETLEF_FALSE or DETLEF_TRUE.
Returns
DETLEF_OK on success; otherwise a DetlefStatus error code.

◆ detlef_value_get_float()

DetlefStatus detlef_value_get_float ( DetlefAccess *  a,
DetlefHandle  handle,
double *  out 
)

Read a float value. Other value types are rejected rather than converted.

Parameters
aBorrowed callback access. Must not be freed, saved, or used outside its current callback.
handleBorrowed float value handle. Not consumed.
[out]outReceives the floating-point value.
Returns
DETLEF_OK on success; otherwise a DetlefStatus error code.

◆ detlef_value_get_integer()

DetlefStatus detlef_value_get_integer ( DetlefAccess *  a,
DetlefHandle  handle,
int64_t *  out 
)

Read an integer value. Other value types are rejected rather than converted.

Parameters
aBorrowed callback access. Must not be freed, saved, or used outside its current callback.
handleBorrowed integer value handle. Not consumed.
[out]outReceives the signed 64-bit integer.
Returns
DETLEF_OK on success; otherwise a DetlefStatus error code.

◆ detlef_value_get_string()

DetlefStatus detlef_value_get_string ( DetlefAccess *  a,
DetlefHandle  handle,
DetlefText *  out 
)

Copy a string value into owned UTF-8 text. Other value types are rejected.

Parameters
aBorrowed callback access. Must not be freed, saved, or used outside its current callback.
handleBorrowed string value handle. Not consumed.
[out]outReceives owned UTF-8 text without a trailing NUL. Must be freed once with detlef_text_free().
Returns
DETLEF_OK on success; otherwise a DetlefStatus error code.

◆ detlef_value_integer()

DetlefStatus detlef_value_integer ( DetlefAccess *  a,
int64_t  value,
DetlefHandle *  out 
)

Create a signed 64-bit integer value.

Parameters
aBorrowed callback access. Must not be freed, saved, or used outside its current callback.
valueSigned 64-bit integer to store.
[out]outOn success, receives an owned integer value handle. Release with detlef_handle_release() unless transferred as a callback result.
Returns
DETLEF_OK on success; otherwise a DetlefStatus error code.

◆ detlef_value_none()

DetlefStatus detlef_value_none ( DetlefAccess *  a,
DetlefHandle *  out 
)

Create the language value none. Its handle is distinct from zero, which means no result.

Parameters
aBorrowed callback access. Must not be freed, saved, or used outside its current callback.
[out]outOn success, receives an owned handle to the language value none. Release with detlef_handle_release() unless transferred as a callback result.
Returns
DETLEF_OK on success; otherwise a DetlefStatus error code.

◆ detlef_value_string()

DetlefStatus detlef_value_string ( DetlefAccess *  a,
DetlefSlice  input,
DetlefHandle *  out 
)

Create a string by copying the supplied UTF-8 bytes. Embedded NUL bytes are permitted.

Parameters
aBorrowed callback access. Must not be freed, saved, or used outside its current callback.
inputBorrowed UTF-8 bytes to copy. Storage may be released after the call.
[out]outOn success, receives an owned string value handle. Release with detlef_handle_release() unless transferred as a callback result.
Returns
DETLEF_OK on success; otherwise a DetlefStatus error code.

◆ detlef_value_to_string()

DetlefStatus detlef_value_to_string ( DetlefAccess *  a,
DetlefHandle  handle,
DetlefText *  out 
)

Format a value as text. Strings are returned as their contents; arrays and records use JSON representation.

Parameters
aBorrowed callback access. Must not be freed, saved, or used outside its current callback.
handleBorrowed runtime value handle to format. Not consumed.
[out]outReceives owned UTF-8 text without a trailing NUL. Must be freed once with detlef_text_free().
Returns
DETLEF_OK on success; otherwise a DetlefStatus error code.