mbed I/F binding for mruby
Dependents: mruby_mbed_web mirb_mbed
mbed-mruby
How to use
Class
include/mruby/object.h@1:8ccd1d494a4b, 2015-04-13 (annotated)
- Committer:
- mzta
- Date:
- Mon Apr 13 05:20:15 2015 +0000
- Revision:
- 1:8ccd1d494a4b
- Parent:
- 0:158c61bb030f
- code refactoring.; - add SPI, SPISlave, I2C class to mruby-mbed (Incomplete).
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mzta | 0:158c61bb030f | 1 | /* |
mzta | 0:158c61bb030f | 2 | ** mruby/object.h - mruby object 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_OBJECT_H |
mzta | 0:158c61bb030f | 8 | #define MRUBY_OBJECT_H |
mzta | 0:158c61bb030f | 9 | |
mzta | 0:158c61bb030f | 10 | #define MRB_OBJECT_HEADER \ |
mzta | 0:158c61bb030f | 11 | enum mrb_vtype tt:8;\ |
mzta | 0:158c61bb030f | 12 | uint32_t color:3;\ |
mzta | 0:158c61bb030f | 13 | uint32_t flags:21;\ |
mzta | 0:158c61bb030f | 14 | struct RClass *c;\ |
mzta | 0:158c61bb030f | 15 | struct RBasic *gcnext |
mzta | 0:158c61bb030f | 16 | |
mzta | 0:158c61bb030f | 17 | /* white: 011, black: 100, gray: 000 */ |
mzta | 0:158c61bb030f | 18 | #define MRB_GC_GRAY 0 |
mzta | 0:158c61bb030f | 19 | #define MRB_GC_WHITE_A 1 |
mzta | 0:158c61bb030f | 20 | #define MRB_GC_WHITE_B (1 << 1) |
mzta | 0:158c61bb030f | 21 | #define MRB_GC_BLACK (1 << 2) |
mzta | 0:158c61bb030f | 22 | #define MRB_GC_WHITES (MRB_GC_WHITE_A | MRB_GC_WHITE_B) |
mzta | 0:158c61bb030f | 23 | #define MRB_GC_COLOR_MASK 7 |
mzta | 0:158c61bb030f | 24 | |
mzta | 0:158c61bb030f | 25 | #define paint_gray(o) ((o)->color = MRB_GC_GRAY) |
mzta | 0:158c61bb030f | 26 | #define paint_black(o) ((o)->color = MRB_GC_BLACK) |
mzta | 0:158c61bb030f | 27 | #define paint_white(o) ((o)->color = MRB_GC_WHITES) |
mzta | 0:158c61bb030f | 28 | #define paint_partial_white(s, o) ((o)->color = (s)->current_white_part) |
mzta | 0:158c61bb030f | 29 | #define is_gray(o) ((o)->color == MRB_GC_GRAY) |
mzta | 0:158c61bb030f | 30 | #define is_white(o) ((o)->color & MRB_GC_WHITES) |
mzta | 0:158c61bb030f | 31 | #define is_black(o) ((o)->color & MRB_GC_BLACK) |
mzta | 0:158c61bb030f | 32 | #define is_dead(s, o) (((o)->color & other_white_part(s) & MRB_GC_WHITES) || (o)->tt == MRB_TT_FREE) |
mzta | 0:158c61bb030f | 33 | #define flip_white_part(s) ((s)->current_white_part = other_white_part(s)) |
mzta | 0:158c61bb030f | 34 | #define other_white_part(s) ((s)->current_white_part ^ MRB_GC_WHITES) |
mzta | 0:158c61bb030f | 35 | |
mzta | 0:158c61bb030f | 36 | struct RBasic { |
mzta | 0:158c61bb030f | 37 | MRB_OBJECT_HEADER; |
mzta | 0:158c61bb030f | 38 | }; |
mzta | 0:158c61bb030f | 39 | #define mrb_basic_ptr(v) ((struct RBasic*)(mrb_ptr(v))) |
mzta | 0:158c61bb030f | 40 | |
mzta | 0:158c61bb030f | 41 | struct RObject { |
mzta | 0:158c61bb030f | 42 | MRB_OBJECT_HEADER; |
mzta | 0:158c61bb030f | 43 | struct iv_tbl *iv; |
mzta | 0:158c61bb030f | 44 | }; |
mzta | 0:158c61bb030f | 45 | #define mrb_obj_ptr(v) ((struct RObject*)(mrb_ptr(v))) |
mzta | 0:158c61bb030f | 46 | |
mzta | 0:158c61bb030f | 47 | #define mrb_immediate_p(x) (mrb_type(x) < MRB_TT_HAS_BASIC) |
mzta | 0:158c61bb030f | 48 | #define mrb_special_const_p(x) mrb_immediate_p(x) |
mzta | 0:158c61bb030f | 49 | |
mzta | 0:158c61bb030f | 50 | struct RFiber { |
mzta | 0:158c61bb030f | 51 | MRB_OBJECT_HEADER; |
mzta | 0:158c61bb030f | 52 | struct mrb_context *cxt; |
mzta | 0:158c61bb030f | 53 | }; |
mzta | 0:158c61bb030f | 54 | |
mzta | 0:158c61bb030f | 55 | #endif /* MRUBY_OBJECT_H */ |
mzta | 0:158c61bb030f | 56 |