Sha256: 34a6c3070e85e58bf84a58ed893b8dedcb0d942ee6f9d1f7e8425662f7151d83

Contents?: true

Size: 1.66 KB

Versions: 6

Compression:

Stored size: 1.66 KB

Contents

/**
** @file mruby/boxing_no.h - unboxed mrb_value definition
**
** See Copyright Notice in mruby.h
*/

#ifndef MRUBY_BOXING_NO_H
#define MRUBY_BOXING_NO_H

#define MRB_FIXNUM_SHIFT 0
#define MRB_SYMBOL_SHIFT 0

union mrb_value_union {
#ifndef MRB_WITHOUT_FLOAT
  mrb_float f;
#endif
  void *p;
  mrb_int i;
  mrb_sym sym;
};

typedef struct mrb_value {
  union mrb_value_union value;
  enum mrb_vtype tt;
} mrb_value;

#ifndef MRB_WITHOUT_FLOAT
#define mrb_float_pool(mrb,f) mrb_float_value(mrb,f)
#endif

#define mrb_ptr(o)      (o).value.p
#define mrb_cptr(o)     mrb_ptr(o)
#ifndef MRB_WITHOUT_FLOAT
#define mrb_float(o)    (o).value.f
#endif
#define mrb_fixnum(o)   (o).value.i
#define mrb_symbol(o)   (o).value.sym
#define mrb_type(o)     (o).tt

#define BOXNIX_SET_VALUE(o, ttt, attr, v) do {\
  (o).tt = ttt;\
  (o).attr = v;\
} while (0)

#define SET_NIL_VALUE(r) BOXNIX_SET_VALUE(r, MRB_TT_FALSE, value.i, 0)
#define SET_FALSE_VALUE(r) BOXNIX_SET_VALUE(r, MRB_TT_FALSE, value.i, 1)
#define SET_TRUE_VALUE(r) BOXNIX_SET_VALUE(r, MRB_TT_TRUE, value.i, 1)
#define SET_BOOL_VALUE(r,b) BOXNIX_SET_VALUE(r, b ? MRB_TT_TRUE : MRB_TT_FALSE, value.i, 1)
#define SET_INT_VALUE(r,n) BOXNIX_SET_VALUE(r, MRB_TT_FIXNUM, value.i, (n))
#ifndef MRB_WITHOUT_FLOAT
#define SET_FLOAT_VALUE(mrb,r,v) BOXNIX_SET_VALUE(r, MRB_TT_FLOAT, value.f, (v))
#endif
#define SET_SYM_VALUE(r,v) BOXNIX_SET_VALUE(r, MRB_TT_SYMBOL, value.sym, (v))
#define SET_OBJ_VALUE(r,v) BOXNIX_SET_VALUE(r, (((struct RObject*)(v))->tt), value.p, (v))
#define SET_CPTR_VALUE(mrb,r,v) BOXNIX_SET_VALUE(r, MRB_TT_CPTR, value.p, v)
#define SET_UNDEF_VALUE(r) BOXNIX_SET_VALUE(r, MRB_TT_UNDEF, value.i, 0)

#endif  /* MRUBY_BOXING_NO_H */

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
script_core-0.2.7 ext/enterprise_script_service/mruby/include/mruby/boxing_no.h
script_core-0.2.6 ext/enterprise_script_service/mruby/include/mruby/boxing_no.h
script_core-0.2.5 ext/enterprise_script_service/mruby/include/mruby/boxing_no.h
script_core-0.2.4 ext/enterprise_script_service/mruby/include/mruby/boxing_no.h
script_core-0.2.3 ext/enterprise_script_service/mruby/include/mruby/boxing_no.h
script_core-0.2.2 ext/enterprise_script_service/mruby/include/mruby/boxing_no.h