Ejemplo n.º 1
0
// Class returns the class with the given name and superclass. Note that
// if you call this with a class that doesn't exist, mruby will abort the
// application (like a panic, but not a Go panic).
//
// super can be nil, in which case the Object class will be used.
func (m *Mrb) Class(name string, super *Class) *Class {
	var class *C.struct_RClass
	if super == nil {
		class = C.mrb_class_get(m.state, C.CString(name))
	} else {
		class = C.mrb_class_get_under(m.state, super.class, C.CString(name))
	}

	return newClass(m, class)
}
Ejemplo n.º 2
0
// Class returns the class with the given name and superclass. Note that
// if you call this with a class that doesn't exist, mruby will abort the
// application (like a panic, but not a Go panic).
//
// super can be nil, in which case the Object class will be used.
func (m *Mrb) Class(name string, super *Class) *Class {
	cs := C.CString(name)
	defer C.free(unsafe.Pointer(cs))

	var class *C.struct_RClass
	if super == nil {
		class = C.mrb_class_get(m.state, cs)
	} else {
		class = C.mrb_class_get_under(m.state, super.class, cs)
	}

	return newClass(m, class)
}
Ejemplo n.º 3
0
func (m *MRuby) ClassGet(name string) *C.struct_RClass {
	return C.mrb_class_get(m.state, C.CString(name))
}