本文整理汇总了Golang中github.com/timob/gojvm/types.NewName函数的典型用法代码示例。如果您正苦于以下问题:Golang NewName函数的具体用法?Golang NewName怎么用?Golang NewName使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewName函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Convert
func (j *JavaToGoSet) Convert(obj *gojvm.Object) (err error) {
iter, err := obj.CallObj(j.env, false, "iterator", types.Class{types.NewName("java.util.Iterator")})
if err != nil {
return
}
return j.JavaToGoIterator.Convert(iter)
}
示例2: RegisterNative
func RegisterNative(className string, method string, paramTypes []string, returnType string, fn interface{}) {
f := func(t string) types.Typed {
switch t {
case "void":
return types.Basic(types.VoidKind)
case "int":
return types.Basic(types.IntKind)
case "long":
return types.Basic(types.LongKind)
case "float":
return types.Basic(types.FloatKind)
case "double":
return types.Basic(types.DoubleKind)
case "boolean":
return types.Basic(types.BoolKind)
default:
return types.Class{types.NewName(t)}
}
return types.Basic(types.VoidKind)
}
var msig types.MethodSignature
for _, v := range paramTypes {
msig.Params = append(msig.Params, f(v))
}
msig.Return = f(returnType)
GetEnv().RegisterNative(className, method, msig, fn)
}
示例3: NewInstanceStr
/*
returns a new *Object of the class named by 'klass' (Wrapper around NewInstance(types.NewName(...)))
*/
func (self *Environment) NewInstanceStr(klass string, params ...interface{}) (obj *Object, err error) {
class, err := self.GetClass(types.NewName(klass))
if err != nil {
return
}
return self.NewInstance(class, params...)
}
示例4: GetName
/*
returns the (potentially cached) types.Name of the class.
*/
func (self *Class) GetName(env *Environment) (name types.Name, err error) {
//log.Printf("Name(miss)")
var cstr string
cstr, _, err = self.CallString(env, false, "getName")
if err == nil {
name = types.NewName(cstr)
}
return
}
示例5: CallStaticObj
func CallStaticObj(class string, method string, retType interface{}, args ...interface{}) (*gojvm.Object, error) {
var t types.Typed
switch v := retType.(type) {
case string:
t = types.Class{types.NewName(v)}
case types.Typed:
t = v
default:
panic("Callable.callObj unknown retType type")
}
env := GetEnv()
cls, err := env.GetClass(types.NewName(class))
if err != nil {
return nil, err
}
return cls.CallObj(env, true, method, t, args...)
}
示例6: CallStaticIntArray
func CallStaticIntArray(class string, method string, args ...interface{}) ([]int, error) {
env := GetEnv()
cls, err := env.GetClass(types.NewName(class))
if err != nil {
return nil, err
}
return cls.CallIntArray(env, true, method, args...)
}
示例7: GetFieldStaticBoolean
func GetFieldStaticBoolean(class string, fieldName string) (bool, error) {
env := GetEnv()
cls, err := env.GetClass(types.NewName(class))
if err != nil {
return false, err
}
return cls.GetBooleanField(env, true, fieldName)
}
示例8: CallStaticDouble
func CallStaticDouble(class string, method string, args ...interface{}) (float64, error) {
env := GetEnv()
cls, err := env.GetClass(types.NewName(class))
if err != nil {
return 0, err
}
return cls.CallDouble(env, true, method, args...)
}
示例9: GetFieldStaticDouble
func GetFieldStaticDouble(class string, fieldName string) (float64, error) {
env := GetEnv()
cls, err := env.GetClass(types.NewName(class))
if err != nil {
return 0, err
}
return cls.GetDoubleField(env, true, fieldName)
}
示例10: CallStaticBoolean
func CallStaticBoolean(class string, method string, args ...interface{}) (bool, error) {
env := GetEnv()
cls, err := env.GetClass(types.NewName(class))
if err != nil {
return false, err
}
return cls.CallBoolean(env, true, method, args...)
}
示例11: GetFieldStaticInt
func GetFieldStaticInt(class string, fieldName string) (int, error) {
env := GetEnv()
cls, err := env.GetClass(types.NewName(class))
if err != nil {
return 0, err
}
return cls.GetIntField(env, true, fieldName)
}
示例12: CallStaticVoid
func CallStaticVoid(class string, method string, args ...interface{}) error {
env := GetEnv()
cls, err := env.GetClass(types.NewName(class))
if err != nil {
return err
}
return cls.CallVoid(env, true, method, args...)
}
示例13: GetFieldStaticObj
func GetFieldStaticObj(class string, fieldName string, retType interface{}) (*gojvm.Object, error) {
env := GetEnv()
var t types.Typed
switch v := retType.(type) {
case string:
t = types.Class{types.NewName(v)}
case types.Typed:
t = v
default:
panic("Callable.callObj unknown retType type")
}
cls, err := env.GetClass(types.NewName(class))
if err != nil {
return nil, err
}
return cls.GetObjField(env, true, fieldName, t)
}
示例14: CallStaticObjArray
func CallStaticObjArray(class string, method string, retType interface{}, args ...interface{}) (*gojvm.Object, error) {
var t types.Typed
switch v := retType.(type) {
case string:
t = types.Array{types.Class{types.NewName(v)}}
case types.Typed:
t = v
default:
panic("Callable.callObj unknown retType type")
}
return CallStaticObj(class, method, t, args...)
}
示例15: CallObjArray
func (c *Callable) CallObjArray(method string, retType interface{}, args ...interface{}) (*gojvm.Object, error) {
var t types.Typed
switch v := retType.(type) {
case string:
t = types.Array{types.Class{types.NewName(v)}}
case types.Typed:
t = v
default:
panic("Callable.callObj unknown retType type")
}
return c.Obj.CallObj(GetEnv(), false, method, t, args...)
}