mbed I/F binding for mruby
Dependents: mruby_mbed_web mirb_mbed
mbed-mruby
How to use
Class
include/mruby/boxing_no.h@0:158c61bb030f, 2015-03-25 (annotated)
- Committer:
- mzta
- Date:
- Wed Mar 25 17:36:16 2015 +0000
- Revision:
- 0:158c61bb030f
mirb_mbed initial commit;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mzta | 0:158c61bb030f | 1 | /* |
mzta | 0:158c61bb030f | 2 | ** mruby/boxing_no.h - unboxed mrb_value definition |
mzta | 0:158c61bb030f | 3 | ** |
mzta | 0:158c61bb030f | 4 | ** See Copyright Notice in mruby.h |
mzta | 0:158c61bb030f | 5 | */ |
mzta | 0:158c61bb030f | 6 | |
mzta | 0:158c61bb030f | 7 | #ifndef MRUBY_BOXING_NO_H |
mzta | 0:158c61bb030f | 8 | #define MRUBY_BOXING_NO_H |
mzta | 0:158c61bb030f | 9 | |
mzta | 0:158c61bb030f | 10 | #define MRB_FIXNUM_SHIFT 0 |
mzta | 0:158c61bb030f | 11 | #define MRB_TT_HAS_BASIC MRB_TT_OBJECT |
mzta | 0:158c61bb030f | 12 | |
mzta | 0:158c61bb030f | 13 | typedef struct mrb_value { |
mzta | 0:158c61bb030f | 14 | union { |
mzta | 0:158c61bb030f | 15 | mrb_float f; |
mzta | 0:158c61bb030f | 16 | void *p; |
mzta | 0:158c61bb030f | 17 | mrb_int i; |
mzta | 0:158c61bb030f | 18 | mrb_sym sym; |
mzta | 0:158c61bb030f | 19 | } value; |
mzta | 0:158c61bb030f | 20 | enum mrb_vtype tt; |
mzta | 0:158c61bb030f | 21 | } mrb_value; |
mzta | 0:158c61bb030f | 22 | |
mzta | 0:158c61bb030f | 23 | #define mrb_float_pool(mrb,f) mrb_float_value(mrb,f) |
mzta | 0:158c61bb030f | 24 | |
mzta | 0:158c61bb030f | 25 | #define mrb_ptr(o) (o).value.p |
mzta | 0:158c61bb030f | 26 | #define mrb_cptr(o) mrb_ptr(o) |
mzta | 0:158c61bb030f | 27 | #define mrb_float(o) (o).value.f |
mzta | 0:158c61bb030f | 28 | #define mrb_fixnum(o) (o).value.i |
mzta | 0:158c61bb030f | 29 | #define mrb_symbol(o) (o).value.sym |
mzta | 0:158c61bb030f | 30 | #define mrb_type(o) (o).tt |
mzta | 0:158c61bb030f | 31 | |
mzta | 0:158c61bb030f | 32 | #define BOXNIX_SET_VALUE(o, ttt, attr, v) do {\ |
mzta | 0:158c61bb030f | 33 | (o).tt = ttt;\ |
mzta | 0:158c61bb030f | 34 | (o).attr = v;\ |
mzta | 0:158c61bb030f | 35 | } while (0) |
mzta | 0:158c61bb030f | 36 | |
mzta | 0:158c61bb030f | 37 | #define SET_NIL_VALUE(r) BOXNIX_SET_VALUE(r, MRB_TT_FALSE, value.i, 0) |
mzta | 0:158c61bb030f | 38 | #define SET_FALSE_VALUE(r) BOXNIX_SET_VALUE(r, MRB_TT_FALSE, value.i, 1) |
mzta | 0:158c61bb030f | 39 | #define SET_TRUE_VALUE(r) BOXNIX_SET_VALUE(r, MRB_TT_TRUE, value.i, 1) |
mzta | 0:158c61bb030f | 40 | #define SET_BOOL_VALUE(r,b) BOXNIX_SET_VALUE(r, b ? MRB_TT_TRUE : MRB_TT_FALSE, value.i, 1) |
mzta | 0:158c61bb030f | 41 | #define SET_INT_VALUE(r,n) BOXNIX_SET_VALUE(r, MRB_TT_FIXNUM, value.i, (n)) |
mzta | 0:158c61bb030f | 42 | #define SET_FLOAT_VALUE(mrb,r,v) BOXNIX_SET_VALUE(r, MRB_TT_FLOAT, value.f, (v)) |
mzta | 0:158c61bb030f | 43 | #define SET_SYM_VALUE(r,v) BOXNIX_SET_VALUE(r, MRB_TT_SYMBOL, value.sym, (v)) |
mzta | 0:158c61bb030f | 44 | #define SET_OBJ_VALUE(r,v) BOXNIX_SET_VALUE(r, (((struct RObject*)(v))->tt), value.p, (v)) |
mzta | 0:158c61bb030f | 45 | #define SET_PROC_VALUE(r,v) BOXNIX_SET_VALUE(r, MRB_TT_PROC, value.p, v) |
mzta | 0:158c61bb030f | 46 | #define SET_CPTR_VALUE(mrb,r,v) BOXNIX_SET_VALUE(r, MRB_TT_CPTR, value.p, v) |
mzta | 0:158c61bb030f | 47 | #define SET_UNDEF_VALUE(r) BOXNIX_SET_VALUE(r, MRB_TT_UNDEF, value.i, 0) |
mzta | 0:158c61bb030f | 48 | |
mzta | 0:158c61bb030f | 49 | #endif /* MRUBY_BOXING_NO_H */ |
mzta | 0:158c61bb030f | 50 |