|
x-engine-c v0.2.13
The C engine for x-lang
|
Character type implementation. More...
#include "x-eval.h"#include "x-type/buffer.h"#include "x-type/char.h"#include "x-type/int.h"#include "x-type/symbol.h"#include "x-token/sexp/char.h"Macros | |
| #define | sym(S) x_mksymbol(p_base, (x_char_t *)(S)) |
| #define | num(N) x_mkint(p_base, (N)) |
| #define | entry(S, N) x_mkspair(p_base, X_OBJ_FLAG_NONE, sym(S), num(N)) |
| #define | pair(A, B) x_mkspair(p_base, X_OBJ_FLAG_NONE, (A), (B)) |
Functions | |
| x_obj_t * | x_make_char (x_obj_t *p_base, x_obj_flag_t flags, x_int_t cp) |
| x_int_t | x_char_utf8_decode (const x_char_t *bytes, x_int_t nbytes) |
| x_obj_t * | x_type_char_save (x_obj_t *p_base, x_obj_t *p_args) |
| x_obj_t * | x_type_char_struct (x_obj_t *p_base, x_obj_t *p_obj) |
| x_obj_t * | x_type_char_register (x_obj_t *p_base, x_obj_t *p_args) |
| x_obj_t * | x_type_char_make (x_obj_t *p_base, x_obj_t *p_args) |
Variables | |
| x_satom_t | x_type_char_name = x_obj_set(x_type_atom_obj, X_OBJ_FLAG_NONE, { .s = (x_char_t *)X_TYPE_CHAR_NAME }) |
| x_satom_t | x_type_char_make_prim = x_obj_set(x_type_atom_obj, X_OBJ_FLAG_NONE, { (x_obj_t *)&x_type_char_make }) |
| x_satom_t | x_type_char_struct_prim = x_obj_set(x_type_atom_obj, X_OBJ_FLAG_NONE, { (x_obj_t *)&x_type_char_struct }) |
| x_satom_t | x_type_char_save_prim = x_obj_set(x_type_atom_obj, X_OBJ_FLAG_NONE, { (x_obj_t *)&x_type_char_save }) |
Character type implementation.
| #define entry | ( | S, | |
| N | |||
| ) | x_mkspair(p_base, X_OBJ_FLAG_NONE, sym(S), num(N)) |
| #define num | ( | N | ) | x_mkint(p_base, (N)) |
| #define pair | ( | A, | |
| B | |||
| ) | x_mkspair(p_base, X_OBJ_FLAG_NONE, (A), (B)) |
| #define sym | ( | S | ) | x_mksymbol(p_base, (x_char_t *)(S)) |
Decode a UTF-8 byte sequence into a code point.
Bytes are read unsigned. The byte count is supplied by the caller (derived from the lead byte), so no bounds scanning is done here.
| bytes | const x_char_t* – Start of the UTF-8 sequence |
| nbytes | x_int_t – Number of bytes in the sequence (1-4) |
| x_obj_t * x_make_char | ( | x_obj_t * | p_base, |
| x_obj_flag_t | flags, | ||
| x_int_t | cp | ||
| ) |
Allocate a heap character object with a given value.
Builds a stack-based argument list and delegates to x_type_char_make.
| p_base | x_obj_t* – Base (execution context) |
| flags | x_obj_flag_t – Object flags |
| cp | x_int_t – Unicode code point |
Type-system make callback for character objects.
Extracts the character value and optional flags from p_args, then allocates a heap object via x_obj_make.
| p_base | x_obj_t* – Base (execution context) |
| p_args | x_obj_t* – (char-value . (flags | nil)) |
Register or retrieve the character type on the base context.
| p_base | x_obj_t* – Base (execution context) |
| p_args | x_obj_t* – Unused |
Build the character type descriptor struct.
Populates name, make, analyse, read, write, and display callbacks. Also builds an alist of named character constants (alarm, backspace, delete, escape, newline, null, return, space, tab) as type data.
| p_base | x_obj_t* – Base (execution context) |
| p_obj | x_obj_t* – Unused |
Build the character type descriptor struct.
| x_satom_t x_type_char_make_prim = x_obj_set(x_type_atom_obj, X_OBJ_FLAG_NONE, { (x_obj_t *)&x_type_char_make }) |
| x_satom_t x_type_char_name = x_obj_set(x_type_atom_obj, X_OBJ_FLAG_NONE, { .s = (x_char_t *)X_TYPE_CHAR_NAME }) |
| x_satom_t x_type_char_save_prim = x_obj_set(x_type_atom_obj, X_OBJ_FLAG_NONE, { (x_obj_t *)&x_type_char_save }) |
| x_satom_t x_type_char_struct_prim = x_obj_set(x_type_atom_obj, X_OBJ_FLAG_NONE, { (x_obj_t *)&x_type_char_struct }) |