Пример #1
0
func (self *Environment) getObjectField(o *Object, static bool, mname string, rType types.Typed) (meth *Field, err error) {
	class, err := self.GetObjectClass(o)
	defer self.DeleteLocalClassRef(class)
	if err != nil {
		return
	}

	cmethod := C.CString(mname)
	defer C.free(unsafe.Pointer(cmethod))
	cform := C.CString(rType.TypeString())
	defer C.free(unsafe.Pointer(cform))

	var m C.jfieldID
	if static {
		//todo
	} else {
		m = C.envGetFieldID(self.env, class.class, cmethod, cform)
	}
	if m == nil {
		err = self.ExceptionOccurred()
		return nil, err
	}

	return &Field{m}, nil
}
Пример #2
0
/*
	Returns the signature string for the configured environment, return type and parameters
	(exported for convenience) ;

	Reflection is handled by ParameterString
*/
func FormFor(ctx *Environment, ret types.Typed, params ...interface{}) (s string, err error) {
	s, err = ParameterString(ctx, params...)
	if err == nil {
		s = s + ret.TypeString()
	}
	return
}
Пример #3
0
func (self *Environment) getClassField(c *Class, static bool, mname string, rType types.Typed) (meth *Field, err error) {
	cmethod := C.CString(mname)
	defer C.free(unsafe.Pointer(cmethod))
	cform := C.CString(rType.TypeString())
	defer C.free(unsafe.Pointer(cform))

	var m C.jfieldID
	if !static {
		//todo
	} else {
		m = C.envGetStaticFieldID(self.env, c.class, cmethod, cform)
	}
	if m == nil {
		err = self.ExceptionOccurred()
		return nil, err
	}

	return &Field{m}, nil
}