LispBM
Loading...
Searching...
No Matches
Macros | Functions | Variables
print.c File Reference
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <inttypes.h>
#include <lbm_types.h>
#include <lbm_custom_type.h>
#include "print.h"
#include "heap.h"
#include "symrepr.h"
#include "stack.h"
#include "lbm_channel.h"
Include dependency graph for print.c:

Macros

#define PRINT   1
 
#define PRINT_SPACE   2
 
#define START_LIST   3
 
#define CONTINUE_LIST   4
 
#define END_LIST   5
 
#define PRINT_DOT   6
 
#define START_ARRAY   7
 
#define CONTINUE_ARRAY   8
 
#define END_ARRAY   9
 
#define EMIT_BUFFER_SIZE   30
 
#define EMIT_FAILED   -1
 
#define EMIT_OK   0
 

Functions

bool lbm_value_is_printable_string (lbm_value v, char **str)
 
static int push_n (lbm_stack_t *s, lbm_uint *values, lbm_uint n)
 
int lbm_print_init (lbm_uint print_stack_size)
 
static int print_emit_string (lbm_char_channel_t *chan, char *str)
 
static int print_emit_char (lbm_char_channel_t *chan, char c)
 
static int emit_escape (lbm_char_channel_t *chan, char c)
 
static int print_emit_string_value (lbm_char_channel_t *chan, char *str)
 
static int print_emit_symbol (lbm_char_channel_t *chan, lbm_value sym)
 
static int print_emit_i (lbm_char_channel_t *chan, lbm_int v)
 
static int print_emit_u (lbm_char_channel_t *chan, lbm_uint v, bool ps)
 
static int print_emit_byte (lbm_char_channel_t *chan, uint8_t v, bool ps)
 
static int print_emit_float (lbm_char_channel_t *chan, float v, bool ps)
 
static int print_emit_double (lbm_char_channel_t *chan, double v, bool ps)
 
static int print_emit_u32 (lbm_char_channel_t *chan, uint32_t v, bool ps)
 
static int print_emit_i32 (lbm_char_channel_t *chan, int32_t v, bool ps)
 
static int print_emit_u64 (lbm_char_channel_t *chan, uint64_t v, bool ps)
 
static int print_emit_i64 (lbm_char_channel_t *chan, int64_t v, bool ps)
 
static int print_emit_continuation (lbm_char_channel_t *chan, lbm_value v)
 
static int print_emit_custom (lbm_char_channel_t *chan, lbm_value v)
 
static int print_emit_defrag_mem (lbm_char_channel_t *chan, lbm_value v)
 
static int print_emit_channel (lbm_char_channel_t *chan, lbm_value v)
 
static int print_emit_array_data (lbm_char_channel_t *chan, lbm_array_header_t *array)
 
static int print_emit_bytearray (lbm_char_channel_t *chan, lbm_value v)
 
static int lbm_print_internal (lbm_char_channel_t *chan, lbm_value v)
 
int lbm_print_value (char *buf, unsigned int len, lbm_value v)
 

Variables

static lbm_stack_t print_stack
 
static bool print_has_stack = false
 
const char * failed_str = "Error: print failed\n"
 

Macro Definition Documentation

◆ CONTINUE_ARRAY

#define CONTINUE_ARRAY   8

◆ CONTINUE_LIST

#define CONTINUE_LIST   4

◆ EMIT_BUFFER_SIZE

#define EMIT_BUFFER_SIZE   30

◆ EMIT_FAILED

#define EMIT_FAILED   -1

◆ EMIT_OK

#define EMIT_OK   0

◆ END_ARRAY

#define END_ARRAY   9

◆ END_LIST

#define END_LIST   5

◆ PRINT

#define PRINT   1

◆ PRINT_DOT

#define PRINT_DOT   6

◆ PRINT_SPACE

#define PRINT_SPACE   2

◆ START_ARRAY

#define START_ARRAY   7

◆ START_LIST

#define START_LIST   3

Function Documentation

◆ emit_escape()

static int emit_escape ( lbm_char_channel_t *  chan,
char  c 
)
static

◆ lbm_print_init()

int lbm_print_init ( lbm_uint  print_stack_size)

Initialize the print_value subsystem. print value depends on a stack and that stack is initialized here using a storage array provided by the user.

Parameters
print_stack_sizeThe number of uint32_t elements in the array.
Returns
1 for success and 0 for failure.

◆ lbm_print_internal()

static int lbm_print_internal ( lbm_char_channel_t *  chan,
lbm_value  v 
)
static

◆ lbm_print_value()

int lbm_print_value ( char *  buf,
unsigned int  len,
lbm_value  t 
)

Print an lbm_value into a buffer provided by the user. If printing fails, the buffer may contain an error message.

Parameters
bufBuffer to print into.
lenThe size of the buffer in bytes.
tThe value to print.
Returns
negative number for failure and the number of printed characters on success.

◆ lbm_value_is_printable_string()

bool lbm_value_is_printable_string ( lbm_value  v,
char **  str 
)

Check if an lbm_value (very likely) is a printable string

Parameters
vValue to check stringyness of.
Returns
True if the value likely is a string, otherwise false.

◆ print_emit_array_data()

static int print_emit_array_data ( lbm_char_channel_t *  chan,
lbm_array_header_t *  array 
)
static

◆ print_emit_byte()

static int print_emit_byte ( lbm_char_channel_t *  chan,
uint8_t  v,
bool  ps 
)
static

◆ print_emit_bytearray()

static int print_emit_bytearray ( lbm_char_channel_t *  chan,
lbm_value  v 
)
static

◆ print_emit_channel()

static int print_emit_channel ( lbm_char_channel_t *  chan,
lbm_value  v 
)
static

◆ print_emit_char()

static int print_emit_char ( lbm_char_channel_t *  chan,
char  c 
)
static

◆ print_emit_continuation()

static int print_emit_continuation ( lbm_char_channel_t *  chan,
lbm_value  v 
)
static

◆ print_emit_custom()

static int print_emit_custom ( lbm_char_channel_t *  chan,
lbm_value  v 
)
static

◆ print_emit_defrag_mem()

static int print_emit_defrag_mem ( lbm_char_channel_t *  chan,
lbm_value  v 
)
static

◆ print_emit_double()

static int print_emit_double ( lbm_char_channel_t *  chan,
double  v,
bool  ps 
)
static

◆ print_emit_float()

static int print_emit_float ( lbm_char_channel_t *  chan,
float  v,
bool  ps 
)
static

◆ print_emit_i()

static int print_emit_i ( lbm_char_channel_t *  chan,
lbm_int  v 
)
static

◆ print_emit_i32()

static int print_emit_i32 ( lbm_char_channel_t *  chan,
int32_t  v,
bool  ps 
)
static

◆ print_emit_i64()

static int print_emit_i64 ( lbm_char_channel_t *  chan,
int64_t  v,
bool  ps 
)
static

◆ print_emit_string()

static int print_emit_string ( lbm_char_channel_t *  chan,
char *  str 
)
static

◆ print_emit_string_value()

static int print_emit_string_value ( lbm_char_channel_t *  chan,
char *  str 
)
static

◆ print_emit_symbol()

static int print_emit_symbol ( lbm_char_channel_t *  chan,
lbm_value  sym 
)
static

◆ print_emit_u()

static int print_emit_u ( lbm_char_channel_t *  chan,
lbm_uint  v,
bool  ps 
)
static

◆ print_emit_u32()

static int print_emit_u32 ( lbm_char_channel_t *  chan,
uint32_t  v,
bool  ps 
)
static

◆ print_emit_u64()

static int print_emit_u64 ( lbm_char_channel_t *  chan,
uint64_t  v,
bool  ps 
)
static

◆ push_n()

static int push_n ( lbm_stack_t *  s,
lbm_uint *  values,
lbm_uint  n 
)
static

Variable Documentation

◆ failed_str

const char* failed_str = "Error: print failed\n"

◆ print_has_stack

bool print_has_stack = false
static

◆ print_stack

lbm_stack_t print_stack
static