Categorygithub.com/elct9620/mruby-go
repositorypackage
0.0.0-20241024123434-ee92cf7f0b21
Repository: https://github.com/elct9620/mruby-go.git
Documentation: pkg.go.dev

# Packages

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# README

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)
}