示例#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)
}
示例#2
0
文件: mruby.go 项目: ujun/go-mruby
// 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)
}
示例#3
0
文件: mruby.go 项目: manveru/go-mruby
func (m *MRuby) ClassGet(name string) *C.struct_RClass {
	return C.mrb_class_get(m.state, C.CString(name))
}