DETLEF C SDK
Native embedding and package authoring
Loading...
Searching...
No Matches
Embedding Helpers

Functions

static DetlefSlice detlef_slice (const void *data, size_t len)
 
static DetlefSlice detlef_cstr (const char *text)
 
static DetlefNamed detlef_named (DetlefSlice name, DetlefHandle handle)
 
static DetlefNamed detlef_named_cstr (const char *name, DetlefHandle handle)
 
static DetlefStatus detlef_execute_cstr (DetlefAccess *access, const char *source, DetlefHandle *result)
 
static DetlefStatus detlef_value_string_cstr (DetlefAccess *access, const char *text, DetlefHandle *result)
 
static DetlefStatus detlef_function_value_string_cstr (DetlefFunctionAccess *access, const char *text, DetlefHandle *result)
 
static DetlefStatus detlef_register_function_cstr (DetlefAccess *access, const char *name, const DetlefNamed *parameters, size_t count, const DetlefNamed *variadic, DetlefFunctionCallback callback, void *data)
 
static DetlefStatus detlef_register_control_cstr (DetlefAccess *access, const char *name, DetlefCallback callback, void *data)
 
static DetlefStatus detlef_package_function_cstr (DetlefAccess *access, DetlefHandle package, const char *name, const DetlefNamed *parameters, size_t count, const DetlefNamed *variadic, DetlefFunctionCallback callback, void *data)
 
static DetlefStatus detlef_package_control_cstr (DetlefAccess *access, DetlefHandle package, const char *name, DetlefCallback callback, void *data)
 

Detailed Description

Function Documentation

◆ detlef_cstr()

static DetlefSlice detlef_cstr ( const char *  text)
inlinestatic

Borrow a NUL-terminated string, excluding its terminator. NULL means an empty slice. Use detlef_slice() for text containing embedded NUL bytes.

Parameters
textBorrowed NUL-terminated UTF-8 text.
Returns
A borrowed byte slice. No allocation is made.

Definition at line 33 of file detlef_helpers.h.

◆ detlef_execute_cstr()

static DetlefStatus detlef_execute_cstr ( DetlefAccess *  access,
const char *  source,
DetlefHandle *  result 
)
inlinestatic

Execute NUL-terminated source; return the ABI status and an owned result.

Parameters
accessBorrowed live callback access. Must not be saved or freed.
sourceBorrowed NUL-terminated UTF-8 source.
[out]resultReceives an owned handle on success. Must be released with the matching handle-release operation unless transferred as a callback result.
Returns
The underlying DETLEF_* status. Input handles are not consumed.

Definition at line 73 of file detlef_helpers.h.

◆ detlef_function_value_string_cstr()

static DetlefStatus detlef_function_value_string_cstr ( DetlefFunctionAccess *  access,
const char *  text,
DetlefHandle *  result 
)
inlinestatic

Create an owned string value through limited Function access.

Parameters
accessBorrowed live callback access. Must not be saved or freed.
textBorrowed NUL-terminated UTF-8 text.
[out]resultReceives an owned handle on success. Must be released with the matching handle-release operation unless transferred as a callback result.
Returns
The underlying DETLEF_* status. Input handles are not consumed.

Definition at line 104 of file detlef_helpers.h.

◆ detlef_named()

static DetlefNamed detlef_named ( DetlefSlice  name,
DetlefHandle  handle 
)
inlinestatic

name is borrowed, handle is copied without retaining it. The consuming ABI call determines whether handle must be a type, TypeRef, or value.

Parameters
nameBorrowed UTF-8 name slice, copied without retaining its storage.
handleBorrowed handle. Copying it does not retain or consume it.
Returns
A name/handle pair. Neither the name nor the handle is retained.

Definition at line 46 of file detlef_helpers.h.

◆ detlef_named_cstr()

static DetlefNamed detlef_named_cstr ( const char *  name,
DetlefHandle  handle 
)
inlinestatic

Borrow a NUL-terminated name and pair it with an unretained handle ID.

Parameters
nameBorrowed NUL-terminated name.
handleBorrowed handle. Copying it does not retain or consume it.
Returns
A name/handle pair. Neither the name nor the handle is retained.

Definition at line 59 of file detlef_helpers.h.

◆ detlef_package_control_cstr()

static DetlefStatus detlef_package_control_cstr ( DetlefAccess *  access,
DetlefHandle  package,
const char *  name,
DetlefCallback  callback,
void *  data 
)
inlinestatic

Add a Control to a package; callback code and data remain host-owned.

Parameters
accessBorrowed live callback access. Must not be saved or freed.
packageBorrowed package-builder handle. Not consumed.
nameBorrowed NUL-terminated name.
callbackSynchronous implementation. Its code and data must outlive registrations.
dataCaller-owned callback data, valid while the registration can run.
Returns
The underlying DETLEF_* status. Input handles are not consumed.

Definition at line 188 of file detlef_helpers.h.

◆ detlef_package_function_cstr()

static DetlefStatus detlef_package_function_cstr ( DetlefAccess *  access,
DetlefHandle  package,
const char *  name,
const DetlefNamed *  parameters,
size_t  count,
const DetlefNamed *  variadic,
DetlefFunctionCallback  callback,
void *  data 
)
inlinestatic

Package parameters use TypeRef handles rather than resolved types.

Parameters
accessBorrowed live callback access. Must not be saved or freed.
packageBorrowed package-builder handle. Not consumed.
nameBorrowed NUL-terminated name.
parametersBorrowed parameter names paired with unresolved TypeRef handles. Handles are not consumed.
countNumber of parameters.
variadicOptional borrowed variadic parameter; NULL means none.
callbackSynchronous implementation. Its code and data must outlive registrations.
dataCaller-owned callback data, valid while the registration can run.
Returns
The underlying DETLEF_* status. Input handles are not consumed.

Definition at line 167 of file detlef_helpers.h.

◆ detlef_register_control_cstr()

static DetlefStatus detlef_register_control_cstr ( DetlefAccess *  access,
const char *  name,
DetlefCallback  callback,
void *  data 
)
inlinestatic

Register a Control; callback code and data must outlive the registration.

Parameters
accessBorrowed live callback access. Must not be saved or freed.
nameBorrowed NUL-terminated name.
callbackSynchronous implementation. Its code and data must outlive registrations.
dataCaller-owned callback data, valid while the registration can run.
Returns
The underlying DETLEF_* status. Input handles are not consumed.

Definition at line 143 of file detlef_helpers.h.

◆ detlef_register_function_cstr()

static DetlefStatus detlef_register_function_cstr ( DetlefAccess *  access,
const char *  name,
const DetlefNamed *  parameters,
size_t  count,
const DetlefNamed *  variadic,
DetlefFunctionCallback  callback,
void *  data 
)
inlinestatic

Parameters use resolved type handles. Callback code and data must outlive their registrations. Function access remains distinct from Control access.

Parameters
accessBorrowed live callback access. Must not be saved or freed.
nameBorrowed NUL-terminated name.
parametersBorrowed parameter names paired with resolved type descriptors. Handles are not consumed.
countNumber of parameters.
variadicOptional borrowed variadic parameter; NULL means none.
callbackSynchronous implementation. Its code and data must outlive registrations.
dataCaller-owned callback data, valid while the registration can run.
Returns
The underlying DETLEF_* status. Input handles are not consumed.

Definition at line 125 of file detlef_helpers.h.

◆ detlef_slice()

static DetlefSlice detlef_slice ( const void *  data,
size_t  len 
)
inlinestatic

Borrow exactly len bytes, including any embedded NUL bytes. The caller must keep data valid for the consuming call. UTF-8 validation happens in DETLEF.

Parameters
dataBorrowed byte storage, valid for len bytes.
lenNumber of supplied bytes.
Returns
A borrowed byte slice. No allocation is made.

Definition at line 20 of file detlef_helpers.h.

◆ detlef_value_string_cstr()

static DetlefStatus detlef_value_string_cstr ( DetlefAccess *  access,
const char *  text,
DetlefHandle *  result 
)
inlinestatic

Create an owned string value from NUL-terminated text.

Parameters
accessBorrowed live callback access. Must not be saved or freed.
textBorrowed NUL-terminated UTF-8 text.
[out]resultReceives an owned handle on success. Must be released with the matching handle-release operation unless transferred as a callback result.
Returns
The underlying DETLEF_* status. Input handles are not consumed.

Definition at line 89 of file detlef_helpers.h.