FANDOM


ExceptionsEdit

PNaCl/EmscriptenEdit

mruby-requireEdit

  • iij version
    • requires mruby-env/io/dir/tempfile
    • only supports script loading
  • mattn version
    • supports dynamic library loading

user defined object allocationEdit

  • use MRB_SET_INSTANCE_TT
    • equivalent to rb_define_alloc_func
    • though it just sets allocating ruby object type
  • need to allocate data if MRB_TT_DATA is set.
    • type and pointer must be set
    • DATA_PTR and DATA_TYPE is just a macro so the return of it can be assigned

mrbgemsEdit

  • document
  • enabling
  • mgem
  • MRuby::Build#gem
    • String is treated as mrbgem path
    • Hash(order is the priority)
      •  :core : mrbgem path "${MRUBY_ROOT}/mrbgems/#{value of :core}"
        • example "conf.gem :core => 'mruby-time'"
      •  :github : git url of "https://github.com/#{value of :github}.git"
        • example "conf.gem :github => 'take-cheeze/mruby-msgpack'"
      •  :bitbucket: git url of "https://bitbucket.org/#{value of :bitbucket}"
        • example "conf.gem :bitbucket => 'masahino/mruby-skkdic'"
      •  :git : git url. cloned when cleaned
      •  :branch : used with repository URL. specifies with branch to use in repository
    • If a block is passed it will be called after the gem spec's block
  • MRuby::Build#gembox
    • mrbgem set to import multiple mrbgems
    • by default 'default' and 'full-core' is available
      • 'default': default gembox. mruby-strintg-utf8 is not included in this
      • 'full-core': gembox of all gems that can be added with ":core"

gemsEdit

BlockEdit

  • One of the most powerful feature of ruby.
  • to call given block to function use **yield**.

Garbage CollectorEdit

  • root_scan_phase scans marks root
  • "mrb_iv_set"ed children(is in iv_tbl) will be marked if parent is marked
  • All the mrb_value in RStruct will be marked.
  • to mark mrb_value use mrb_gc_mark_value
  • to mart RBasic* use mrb_gv_mark
  • built-in type(e.g. int, float) is ignored
  • Unable to have mark function(currently)

Data typeEdit

  • mrb_sym
    • string reference like flyweight pattern. pooled string pointer
    • get it from mrb_intern(mrb, sym_str)
    • mrb_intern2 has string length argument
  • mrb_irep
    • VM codes of mruby? Symbol table?
    • mrb_dump_irep/mrb_bdump_irep outputs mruby binary
    • mrb_cdump_irep outputs C code
    • to load binary outputed by "mrb -B" use mrb_read_irep, use mrb_load_irep to load if "-C","-B" wasn't passed.

mrb_get_args() formatEdit

char mruby type C type
o Object mrb_value
S String mrb_value
A Array mrb_value
H Hash mrb_value
s String char*, int
z String char*
a Array mrb_value*, mrb_int
f Float mrb_float
i integer mrb_int
b boolean mrb_bool
n Symbol mrb_sym
d Data void*, mrb_data_type
& Block mrb_value
* rest argument mrb_value*, int
optional after this character the following argument will be optional
 ? optional argument retrieved mrb_bool

Built-in ClassesEdit

  • RBasic
    • base of all built-in classes
    • use RBASIC to get pointer from mrb_value
    • To create mrb_value use mrb_obj_value(p)
  • RStruct
    • Tuple
    • able to access with index and symbol
  • RData
    • C struct wrapper.
    • pointer getting
      • mrb_get_datatype: if error returns NULL
      • mrb_check_datatype: if error throws exception

C language translaterEdit

  • How to use.
  • mrbc -C${symbol} ${file}.rb: outputs C function
    • ${file}.c: extern void ${symbol}(mrb_state* mrb) {}
  • mrbc -B${symbol} ${file}.rb: outputs C array mruby binary
    • ${file}.c: extern const char hello[] = {}
  • mrbc ${file}.rb: outputs mruby binary
    • ${file}.mrb: mruby binary

Native ClientEdit

  • How to build mruby

FiberEdit

Weak ReferenceEdit

Native ClientEdit

EmscriptenEdit

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.