klisp

an open source interpreter for the Kernel Programming Language.
git clone http://git.hanabi.in/repos/klisp.git
Log | Files | Refs | README

kbytevector.h (1692B)


      1 /*
      2 ** kbytevector.h
      3 ** Kernel Byte Vectors
      4 ** See Copyright Notice in klisp.h
      5 */
      6 
      7 #ifndef kbytevector_h
      8 #define kbytevector_h
      9 
     10 #include "kobject.h"
     11 #include "kstate.h"
     12 
     13 /* TODO change names to be lua-like (e.g. klispBB_new, etc) */
     14 
     15 /* General constructor for bytevectors */
     16 TValue kbytevector_new_bs_g(klisp_State *K, bool m, const uint8_t *buf, 
     17                             uint32_t size);
     18 
     19 /* 
     20 ** Constructors for immutable bytevectors
     21 */
     22 
     23 /* main immutable bytevector constructor */
     24 /* with buffer & size */
     25 TValue kbytevector_new_bs_imm(klisp_State *K, const uint8_t *buf, uint32_t size);
     26 
     27 /* 
     28 ** Constructors for mutable bytevectors
     29 */
     30 
     31 /* main mutable bytevector constructor */
     32 /* with just size */
     33 TValue kbytevector_new_s(klisp_State *K, uint32_t size);
     34 /* with buffer & size */
     35 TValue kbytevector_new_bs(klisp_State *K, const uint8_t *buf, uint32_t size);
     36 /* with size & fill byte */
     37 TValue kbytevector_new_sf(klisp_State *K, uint32_t size, uint8_t fill);
     38 
     39 /* both obj1 and obj2 should be bytevectors, this compares byte by byte
     40    and doesn't differentiate immutable from mutable bytevectors */
     41 bool kbytevector_equalp(klisp_State *K, TValue obj1, TValue obj2);
     42 bool kbytevectorp(TValue obj);
     43 bool kimmutable_bytevectorp(TValue obj);
     44 bool kmutable_bytevectorp(TValue obj);
     45 
     46 /* some macros to access the parts of the bytevectors */
     47 /* LOCK: these are immutable, so they don't need locking */
     48 #define kbytevector_buf(tv_) (tv2bytevector(tv_)->b)
     49 #define kbytevector_size(tv_) (tv2bytevector(tv_)->size)
     50 
     51 #define kbytevector_emptyp(tv_) (kbytevector_size(tv_) == 0)
     52 #define kbytevector_mutablep(tv_) (kis_mutable(tv_))
     53 #define kbytevector_immutablep(tv_) (kis_immutable(tv_))
     54 
     55 #endif