x-engine-c v0.2.13
The C engine for x-lang
Loading...
Searching...
No Matches
char.h File Reference

Character type for the x-lang type system. More...

#include "x-type.h"

Go to the source code of this file.

Macros

#define X_TYPE_CHAR_NAME   "CHARACTER"
 
#define x_obj_type_ischar(B, X)   x_obj_is_type((B), (X), X_TYPE_CHAR_NAME)
 
#define x_charval(X)   x_firstchar((X))
 
#define x_mkchar(B, C)   x_make_char((B), X_OBJ_FLAG_NONE, (C))
 
#define x_mkfchar(B, F, C)   x_make_char((B), (F), (C))
 

Functions

x_obj_tx_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_tx_type_char_struct (x_obj_t *p_base, x_obj_t *p_args)
 
x_obj_tx_type_char_register (x_obj_t *p_base, x_obj_t *p_args)
 
x_obj_tx_type_char_make (x_obj_t *p_base, x_obj_t *p_args)
 
x_obj_tx_type_char_analyse1 (x_obj_t *p_base, x_obj_t *p_args)
 
x_obj_tx_type_char_analyse2 (x_obj_t *p_base, x_obj_t *p_args)
 
x_obj_tx_type_char_read (x_obj_t *p_base, x_obj_t *p_args)
 
x_obj_tx_type_char_write (x_obj_t *p_base, x_obj_t *p_args)
 

Detailed Description

Character type for the x-lang type system.

Author
Jon Ruttan (jonru.nosp@m.ttan.nosp@m.@gmai.nosp@m.l.co.nosp@m.m)

Macro Definition Documentation

◆ x_charval

#define x_charval (   X)    x_firstchar((X))

Extract the character value from a character object.

◆ x_mkchar

#define x_mkchar (   B,
 
)    x_make_char((B), X_OBJ_FLAG_NONE, (C))

Make a character with default flags.

◆ x_mkfchar

#define x_mkfchar (   B,
  F,
 
)    x_make_char((B), (F), (C))

Make a character with explicit flags F.

◆ x_obj_type_ischar

#define x_obj_type_ischar (   B,
 
)    x_obj_is_type((B), (X), X_TYPE_CHAR_NAME)

Test whether object X is a character on base B.

◆ X_TYPE_CHAR_NAME

#define X_TYPE_CHAR_NAME   "CHARACTER"

Type-system symbol name

Function Documentation

◆ x_char_utf8_decode()

x_int_t x_char_utf8_decode ( const x_char_t bytes,
x_int_t  nbytes 
)

Decode an nbytes-long UTF-8 sequence into a code point.

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.

Parameters
bytesconst x_char_t* – Start of the UTF-8 sequence
nbytesx_int_t – Number of bytes in the sequence (1-4)
Returns
x_int_t – The decoded code point

◆ x_make_char()

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 holding code point cp.

Allocate a heap character object with a given value.

Builds a stack-based argument list and delegates to x_type_char_make.

Parameters
p_basex_obj_t* – Base (execution context)
flagsx_obj_flag_t – Object flags
cpx_int_t – Unicode code point
Returns
x_obj_t* – New heap-allocated character object

◆ x_type_char_analyse1()

x_obj_t * x_type_char_analyse1 ( x_obj_t p_base,
x_obj_t p_args 
)

Tokenizer analyse callback (phase 1) for character literals.

◆ x_type_char_analyse2()

x_obj_t * x_type_char_analyse2 ( x_obj_t p_base,
x_obj_t p_args 
)

Tokenizer analyse callback (phase 2) for character literals.

◆ x_type_char_make()

x_obj_t * x_type_char_make ( x_obj_t p_base,
x_obj_t p_args 
)

Type-system make callback for character.

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.

Parameters
p_basex_obj_t* – Base (execution context)
p_argsx_obj_t* – (char-value . (flags | nil))
Returns
x_obj_t* – New heap-allocated character object

◆ x_type_char_read()

x_obj_t * x_type_char_read ( x_obj_t p_base,
x_obj_t p_args 
)

Tokenizer read callback for character literals.

◆ x_type_char_register()

x_obj_t * x_type_char_register ( x_obj_t p_base,
x_obj_t p_args 
)

Register (or retrieve) the character type struct on p_base.

Register or retrieve the character type on the base context.

Parameters
p_basex_obj_t* – Base (execution context)
p_argsx_obj_t* – Unused
Returns
x_obj_t* – Registered type object

◆ x_type_char_struct()

x_obj_t * x_type_char_struct ( x_obj_t p_base,
x_obj_t p_args 
)

Build the character type descriptor struct.

◆ x_type_char_write()

x_obj_t * x_type_char_write ( x_obj_t p_base,
x_obj_t p_args 
)

Type-system write callback for character objects.