|
x-engine-c v0.2.13
The C engine for x-lang
|
Byte buffer type – construction, cursor management, and character I/O. More...
Functions | |
| x_obj_t * | x_make_buffer (x_obj_t *p_base, x_obj_flag_t flags, void *p) |
| x_obj_t * | x_type_buffer_mark (x_obj_t *p_base, x_obj_t *p_args) |
| x_obj_t * | x_type_buffer_save (x_obj_t *p_base, x_obj_t *p_args) |
| x_obj_t * | x_type_buffer_load (x_obj_t *p_base, x_obj_t *p_args) |
| x_obj_t * | x_type_buffer_struct (x_obj_t *p_base, x_obj_t *p_args) |
| x_obj_t * | x_type_buffer_register (x_obj_t *p_base, x_obj_t *p_args) |
| x_obj_t * | x_type_buffer_make (x_obj_t *p_base, x_obj_t *p_args) |
| x_obj_t * | x_type_buffer_reset (x_obj_t *p_base, x_obj_t *p_args) |
| x_obj_t * | x_type_buffer_retain (x_obj_t *p_base, x_obj_t *p_args) |
| x_obj_t * | x_type_buffer_append (x_obj_t *p_base, x_obj_t *p_args) |
| x_obj_t * | x_type_buffer_read (x_obj_t *p_base, x_obj_t *p_args) |
| x_obj_t * | x_type_buffer_read_text (x_obj_t *p_base, x_obj_t *p_args) |
Byte buffer type – construction, cursor management, and character I/O.
| x_obj_t * x_make_buffer | ( | x_obj_t * | p_base, |
| x_obj_flag_t | flags, | ||
| void * | p | ||
| ) |
Allocate a BUFFER wrapping the character array at p.
Both read and write cursors are initialized to point at p.
| p_base | Base (execution context). |
| flags | Object flags (e.g. X_OBJ_FLAG_OWN, X_OBJ_FLAG_RO). |
| p | Pointer to the underlying character array. |
Append a single character at the write cursor.
Writes the character from the second argument and advances the write cursor by one.
| p_base | Base (execution context). |
| p_args | Argument list: (buffer char-object). |
Type-system make handler for BUFFER objects.
Creates a two-level structure: the outer pair holds the base pointer, and the inner pair holds the read and write cursors (both initialized to the base pointer). The X_OBJ_FLAG_OWN flag is set only on the outer object.
| p_base | Base (execution context). |
| p_args | Argument list: (buffer-atom [flags-atom]). |
GC mark handler for BUFFER objects.
Flags the inner bookkeeping pair directly without traversing its slots, since those contain raw char* pointers rather than objects.
| p_base | Base (execution context). |
| p_args | Argument list: (buffer-object flags). |
Read one character from the buffer, extending from stdin if needed.
If the buffer is exhausted and not read-only, reads one character from the base input channel and appends it. Advances the read cursor by one and tracks newlines for error reporting.
| p_base | Base (execution context). |
| p_args | Argument list whose first element is the buffer. |
Read one text character, treating NUL as EOF.
Delegates to x_type_buffer_read() and returns NULL if the result is NULL or the last character read was '\0'.
| p_base | Base (execution context). |
| p_args | Argument list whose first element is the buffer. |
Register (or retrieve) the BUFFER type in the type alist.
| p_base | Base (execution context). |
| p_args | Unused. |
Reset both read and write cursors to the base pointer.
Effectively empties the buffer without deallocating the array.
| p_base | Base (execution context). |
| p_args | Argument list whose first element is the buffer. |
Compact unread data to the front of the underlying array.
Copies the remaining unread bytes to position 0 and adjusts both cursors accordingly, freeing space at the end of the buffer.
| p_base | Base (execution context). |
| p_args | Argument list whose first element is the buffer. |
Build the BUFFER type struct descriptor.
Populates name, mark, and make hooks.
| p_base | Base (execution context). |
| p_args | Unused. |
Build the BUFFER type struct descriptor.
| x_satom_t x_type_buffer_load_prim = x_obj_set(x_type_atom_obj, X_OBJ_FLAG_NONE, { (x_obj_t *)&x_type_buffer_load }) |
| x_satom_t x_type_buffer_make_prim = x_obj_set(x_type_atom_obj, X_OBJ_FLAG_NONE, { (x_obj_t *)&x_type_buffer_make }) |
| x_satom_t x_type_buffer_mark_prim = x_obj_set(x_type_atom_obj, X_OBJ_FLAG_NONE, { (x_obj_t *)&x_type_buffer_mark }) |
| x_satom_t x_type_buffer_name = x_obj_set(x_type_atom_obj, X_OBJ_FLAG_NONE, { .s = (x_char_t *)X_TYPE_BUFFER_NAME }) |
| x_satom_t x_type_buffer_save_prim = x_obj_set(x_type_atom_obj, X_OBJ_FLAG_NONE, { (x_obj_t *)&x_type_buffer_save }) |
| x_satom_t x_type_buffer_struct_prim = x_obj_set(x_type_atom_obj, X_OBJ_FLAG_NONE, { (x_obj_t *)&x_type_buffer_struct }) |