shithub: sl

ref: 108a9de63855e85b23b98edcffa095ffed9eb9f8
dir: /src/cvalues.h/

View raw version
#pragma once

#if defined(BITS64)
#define NWORDS(sz) (((sz)+7)>>3)
#else
#define NWORDS(sz) (((sz)+3)>>2)
#endif

void add_finalizer(cvalue_t *cv);
void sweep_finalizers(void);
void cv_autorelease(cvalue_t *cv);
value_t cvalue_(fltype_t *type, size_t sz, bool nofinalizer);
#define cvalue(type, sz) cvalue_(type, sz, false)
#define cvalue_nofinalizer(type, sz) cvalue_(type, sz, true)
value_t cvalue_from_ref(fltype_t *type, void *ptr, size_t sz);
value_t cvalue_string(size_t sz);
value_t cvalue_static_cstring(const char *str);
value_t string_from_cstrn(char *str, size_t n);
value_t string_from_cstr(char *str);
bool fl_isstring(value_t v) fl_purefn;
void cv_pin(cvalue_t *cv);
value_t size_wrap(size_t sz);
size_t tosize(value_t n);
off_t tooffset(value_t n);
bool isarray(value_t v) fl_purefn;
void cvalue_array_init(fltype_t *ft, value_t arg, void *dest);
size_t cvalue_arraylen(value_t v) fl_purefn;
size_t ctype_sizeof(value_t type);
void to_sized_ptr(value_t v, uint8_t **pdata, size_t *psz);
value_t cvalue_relocate(value_t v);
value_t cvalue_copy(value_t v);
value_t cvalue_compare(value_t a, value_t b) fl_purefn;
value_t cvalue_array_aref(value_t *args);
value_t cvalue_array_aset(value_t *args);
value_t cbuiltin(const char *name, builtin_t f);
value_t return_from_uint64(uint64_t Uaccum);
value_t return_from_int64(int64_t Saccum);
value_t fl_add_any(value_t *args, uint32_t nargs);
value_t fl_neg(value_t n);
value_t fl_mul_any(value_t *args, uint32_t nargs);
bool num_to_ptr(value_t a, fixnum_t *pi, numerictype_t *pt, void **pp);
_Noreturn void divide_by_0_error(void);
value_t fl_div2(value_t a, value_t b);
value_t fl_idiv2(value_t a, value_t b);
void cvalues_init(void);

value_t mk_double(double n);
value_t mk_float(float n);
value_t mk_int32(int32_t n);
value_t mk_uint32(uint32_t n);
value_t mk_int64(int64_t n);
value_t mk_uint64(uint64_t n);
value_t mk_rune(Rune n);
value_t mk_mpint(mpint *n);

size_t llength(value_t v) fl_purefn;