コード例 #1
0
ファイル: mruby.go プロジェクト: vidyacraghav/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 {
	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))
}