LispBM
Macros | Typedefs | Functions
lbm_custom_type.h File Reference
#include <stdbool.h>
#include <stddef.h>
#include <lbm_types.h>
#include <lbm_defines.h>
#include <heap.h>
Include dependency graph for lbm_custom_type.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define CUSTOM_TYPE_VALUE   0
 
#define CUSTOM_TYPE_DESCRIPTOR   1
 
#define CUSTOM_TYPE_DESTRUCTOR   2
 
#define CUSTOM_TYPE_LBM_MEM_SIZE   3
 

Typedefs

typedef bool(* custom_type_destructor) (lbm_uint)
 

Functions

bool lbm_custom_type_create (lbm_uint value, custom_type_destructor fptr, const char *desc, lbm_value *result)
 
bool lbm_custom_type_destroy (lbm_uint *lbm_mem_ptr)
 
static bool lbm_is_custom (lbm_value value)
 
static const char * lbm_get_custom_descriptor (lbm_value value)
 
static lbm_uint lbm_get_custom_value (lbm_value value)
 

Macro Definition Documentation

◆ CUSTOM_TYPE_DESCRIPTOR

#define CUSTOM_TYPE_DESCRIPTOR   1

◆ CUSTOM_TYPE_DESTRUCTOR

#define CUSTOM_TYPE_DESTRUCTOR   2

◆ CUSTOM_TYPE_LBM_MEM_SIZE

#define CUSTOM_TYPE_LBM_MEM_SIZE   3

◆ CUSTOM_TYPE_VALUE

#define CUSTOM_TYPE_VALUE   0

Typedef Documentation

◆ custom_type_destructor

typedef bool(* custom_type_destructor) (lbm_uint)

Function Documentation

◆ lbm_custom_type_create()

bool lbm_custom_type_create ( lbm_uint  value,
custom_type_destructor  fptr,
const char *  desc,
lbm_value result 
)

Create a value of a custom type with a destructor and a description

Parameters
valueThe custom value. This can be a pointer to memory allocated on the C-side.
fptrThe destructor function. This function should free any memory allocated on the C-side.
descA description of the type that will be used for printing.
resultPointer to lbm_value that will hold the value of the custom type.
Returns
true on success or false otherwise.

◆ lbm_custom_type_destroy()

bool lbm_custom_type_destroy ( lbm_uint lbm_mem_ptr)

Called by garbage collector and invokes the destructor on the custom value.

/return true on success or false otherwise.

◆ lbm_get_custom_descriptor()

static const char* lbm_get_custom_descriptor ( lbm_value  value)
inlinestatic

◆ lbm_get_custom_value()

static lbm_uint lbm_get_custom_value ( lbm_value  value)
inlinestatic

◆ lbm_is_custom()

static bool lbm_is_custom ( lbm_value  value)
inlinestatic