Skip to content

Latest commit

 

History

History
55 lines (41 loc) · 1.58 KB

README.md

File metadata and controls

55 lines (41 loc) · 1.58 KB

mruby-go

Go Reference Test Maintainability codecov

The pure go mruby virtual machine implementation.

Roadmap

The priority task is to make the virtual machine available with limited functions, it still depends on mrbc command to compile RiteBinary.

  • complete the method support
  • complete the class support
  • add mruby capability test

MRB_API

Golang has public and private method design and we can attach method to a struct. Therefore all public method is attach to *mruby.State in mruby-go as preferred method.

func (mrb *State) ObjectInstanceVariableGet(obj RObject, name Symbol) Value {
  return obj.ivGet(name)
}

// Prefer
func (mrb *State) ClassName(class RClass) string {
	if class == nil {
		return ""
	}

	name := mrb.ObjectInstanceVariableGet(class, _classname(mrb)) // <- Prefer this
	if name == nil {
		return ""
	}

	return name.(string)
}

// Avoid
func (mrb *State) ClassName(class RClass) string {
	if class == nil {
		return ""
	}

	name := class.ivGet(_classname(mrb)) // <- Avoid this
	if name == nil {
		return ""
	}

	return name.(string)
}