当前位置: 首页>>代码示例>>Golang>>正文


Golang util.NewObject函数代码示例

本文整理汇总了Golang中v/io/x/jni/util.NewObject函数的典型用法代码示例。如果您正苦于以下问题:Golang NewObject函数的具体用法?Golang NewObject怎么用?Golang NewObject使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了NewObject函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: JavaCaveat

// JavaCaveat converts the provided Go Caveat into a Java Caveat.
func JavaCaveat(env jutil.Env, caveat security.Caveat) (jutil.Object, error) {
	// NOTE(spetrovic): We could call JVomCopy here, but it's painfully slow and this code is
	// on the critical path.

	// Copy the Id field.
	jId, err := jutil.NewObject(env, jIdClass, []jutil.Sign{jutil.ByteArraySign}, []byte(caveat.Id[:]))
	if err != nil {
		return jutil.NullObject, err
	}
	return jutil.NewObject(env, jCaveatClass, []jutil.Sign{idSign, jutil.ByteArraySign}, jId, caveat.ParamVom)
}
开发者ID:vanadium,项目名称:go.jni,代码行数:12,代码来源:util.go

示例2: Java_io_v_v23_security_VPrincipalImpl_nativeCreatePersistentForSigner

//export Java_io_v_v23_security_VPrincipalImpl_nativeCreatePersistentForSigner
func Java_io_v_v23_security_VPrincipalImpl_nativeCreatePersistentForSigner(jenv *C.JNIEnv, jclass C.jclass, jSigner C.jobject, jDir C.jstring) C.jobject {
	env := jutil.Env(uintptr(unsafe.Pointer(jenv)))
	signerObj := jutil.Object(uintptr(unsafe.Pointer(jSigner)))
	signer, err := GoSigner(env, signerObj)
	if err != nil {
		jutil.JThrowV(env, err)
		return nil
	}
	dir := jutil.GoString(env, jutil.Object(uintptr(unsafe.Pointer(jDir))))
	stateSerializer, err := vsecurity.NewPrincipalStateSerializer(dir)
	if err != nil {
		jutil.JThrowV(env, err)
		return nil
	}
	principal, err := vsecurity.NewPrincipalFromSigner(signer, stateSerializer)
	if err != nil {
		jutil.JThrowV(env, err)
		return nil
	}
	ref := jutil.GoNewRef(&principal) // Un-refed when the Java VPrincipalImpl is finalized.
	jPrincipal, err := jutil.NewObject(env, jVPrincipalImplClass, []jutil.Sign{jutil.LongSign, signerSign, blessingStoreSign, blessingRootsSign}, int64(ref), signerObj, jutil.NullObject, jutil.NullObject)
	if err != nil {
		jutil.GoDecRef(ref)
		jutil.JThrowV(env, err)
		return nil
	}
	return C.jobject(unsafe.Pointer(jPrincipal))
}
开发者ID:vanadium,项目名称:go.jni,代码行数:29,代码来源:jni.go

示例3: Java_io_v_v23_security_VSecurity_nativeCreateAuthorizer

//export Java_io_v_v23_security_VSecurity_nativeCreateAuthorizer
func Java_io_v_v23_security_VSecurity_nativeCreateAuthorizer(jenv *C.JNIEnv, jVSecurityClass C.jclass, kind C.jint, jKey C.jobject) C.jobject {
	env := jutil.Env(uintptr(unsafe.Pointer(jenv)))
	var auth security.Authorizer
	switch kind {
	case 0:
		auth = security.AllowEveryone()
	case 1:
		auth = security.EndpointAuthorizer()
	case 2:
		auth = security.DefaultAuthorizer()
	case 3:
		key, err := GoPublicKey(env, jutil.Object(uintptr(unsafe.Pointer(jKey))))
		if err != nil {
			jutil.JThrowV(env, err)
			return nil
		}
		auth = security.PublicKeyAuthorizer(key)
	default:
		return nil
	}
	ref := jutil.GoNewRef(&auth) // Un-refed when the Java PermissionsAuthorizer is finalized
	jAuthorizer, err := jutil.NewObject(env, jutil.Class(uintptr(unsafe.Pointer(jPermissionsAuthorizerClass))), []jutil.Sign{jutil.LongSign}, int64(ref))
	if err != nil {
		jutil.GoDecRef(ref)
		jutil.JThrowV(env, err)
		return nil
	}
	return C.jobject(unsafe.Pointer(jAuthorizer))
}
开发者ID:vanadium,项目名称:go.jni,代码行数:30,代码来源:jni.go

示例4: initDriverFactory

func initDriverFactory(env jutil.Env) error {
	jDriverClass, err := jutil.JFindClass(env, "io/v/android/impl/google/discovery/plugins/ble/Driver")
	if err != nil {
		return err
	}
	factory := func(ctx *context.T, _ string) (ble.Driver, error) {
		env, freeFunc := jutil.GetEnv()
		defer freeFunc()

		jCtx, err := jcontext.JavaContext(env, ctx, nil)
		if err != nil {
			return nil, err
		}
		jDriver, err := jutil.NewObject(env, jDriverClass, []jutil.Sign{contextSign}, jCtx)
		if err != nil {
			return nil, err
		}
		// Reference the driver; it will be de-referenced when the driver is garbage-collected.
		jDriver = jutil.NewGlobalRef(env, jDriver)
		d := &driver{jDriver}
		runtime.SetFinalizer(d, func(*driver) {
			env, freeFunc := jutil.GetEnv()
			jutil.DeleteGlobalRef(env, d.jDriver)
			freeFunc()
		})
		return d, nil
	}
	ble.SetDriverFactory(factory)
	return nil
}
开发者ID:vanadium,项目名称:go.jni,代码行数:30,代码来源:driver.go

示例5: Java_io_v_v23_security_access_PermissionsAuthorizer_nativeCreate

//export Java_io_v_v23_security_access_PermissionsAuthorizer_nativeCreate
func Java_io_v_v23_security_access_PermissionsAuthorizer_nativeCreate(jenv *C.JNIEnv, jPermissionsAuthorizerClass C.jclass, jPermissions C.jobject, jTagType C.jobject) C.jobject {
	env := jutil.Env(uintptr(unsafe.Pointer(jenv)))
	perms, err := GoPermissions(env, jutil.Object(uintptr(unsafe.Pointer(jPermissions))))
	if err != nil {
		jutil.JThrowV(env, err)
		return nil
	}
	tagType, err := jutil.GoVdlType(env, jutil.Object(uintptr(unsafe.Pointer(jTagType))))
	if err != nil {
		jutil.JThrowV(env, err)
		return nil
	}
	authorizer, err := access.PermissionsAuthorizer(perms, tagType)
	if err != nil {
		jutil.JThrowV(env, err)
		return nil
	}
	ref := jutil.GoNewRef(&authorizer) // Un-refed when the Java PermissionsAuthorizer is finalized
	jAuthorizer, err := jutil.NewObject(env, jutil.Class(uintptr(unsafe.Pointer(jPermissionsAuthorizerClass))), []jutil.Sign{jutil.LongSign}, int64(ref))
	if err != nil {
		jutil.GoDecRef(ref)
		jutil.JThrowV(env, err)
		return nil
	}
	return C.jobject(unsafe.Pointer(jAuthorizer))
}
开发者ID:vanadium,项目名称:go.jni,代码行数:27,代码来源:jni.go

示例6: javaUUID

// javaUUID converts a Go UUID into a Java UUID instance.
func javaUUID(env jutil.Env, uuid idiscovery.Uuid) (jutil.Object, error) {
	var high, low int64
	buf := bytes.NewReader(uuid)
	binary.Read(buf, binary.BigEndian, &high)
	binary.Read(buf, binary.BigEndian, &low)
	return jutil.NewObject(env, jUUIDClass, []jutil.Sign{jutil.LongSign, jutil.LongSign}, high, low)
}
开发者ID:vanadium,项目名称:go.jni,代码行数:8,代码来源:util.go

示例7: JavaPublisherEntry

// JavaPublisherEntry converts the provided rpc.PublisherEntry value into a Java
// PublisherEntry object.
// TODO(suharshs): Add PublisherState to the java publisher entry? May not make sense, since there is no
// notification channel in Java.
func JavaPublisherEntry(env jutil.Env, entry rpc.PublisherEntry) (jutil.Object, error) {
	jStatus, err := jutil.NewObject(env, jPublisherEntryClass, []jutil.Sign{jutil.StringSign, jutil.StringSign, jutil.DateTimeSign, jutil.VExceptionSign, jutil.DurationSign, jutil.DateTimeSign, jutil.VExceptionSign}, entry.Name, entry.Server, entry.LastMount, entry.LastMountErr, entry.TTL, entry.LastUnmount, entry.LastUnmountErr)
	if err != nil {
		return jutil.NullObject, err
	}
	return jStatus, nil
}
开发者ID:vanadium,项目名称:go.jni,代码行数:11,代码来源:util.go

示例8: javaStream

// javaStream converts the provided Go stream into a Java Stream object.
func javaStream(env jutil.Env, jContext jutil.Object, stream rpc.Stream) (jutil.Object, error) {
	ref := jutil.GoNewRef(&stream) // Un-refed when the Java stream object is finalized.
	jStream, err := jutil.NewObject(env, jStreamImplClass, []jutil.Sign{contextSign, jutil.LongSign}, jContext, int64(ref))
	if err != nil {
		jutil.GoDecRef(ref)
		return jutil.NullObject, err
	}
	return jStream, nil
}
开发者ID:vanadium,项目名称:go.jni,代码行数:10,代码来源:util.go

示例9: JavaAddressChooser

// JavaAddressChooser converts a Go address chooser function into a Java
// AddressChooser object.
func JavaAddressChooser(env jutil.Env, chooser rpc.AddressChooser) (jutil.Object, error) {
	ref := jutil.GoNewRef(&chooser) // Un-refed when the Java AddressChooser object is finalized.
	jAddressChooser, err := jutil.NewObject(env, jAddressChooserImplClass, []jutil.Sign{jutil.LongSign}, int64(ref))
	if err != nil {
		jutil.GoDecRef(ref)
		return jutil.NullObject, err
	}
	return jAddressChooser, nil
}
开发者ID:vanadium,项目名称:go.jni,代码行数:11,代码来源:util.go

示例10: JavaServerCall

// JavaServerCall converts a Go rpc.ServerCall into a Java ServerCall object.
func JavaServerCall(env jutil.Env, serverCall rpc.ServerCall) (jutil.Object, error) {
	ref := jutil.GoNewRef(&serverCall) // Un-refed when the Java ServerCall object is finalized.
	jServerCall, err := jutil.NewObject(env, jServerCallImplClass, []jutil.Sign{jutil.LongSign}, int64(ref))
	if err != nil {
		jutil.GoDecRef(ref)
		return jutil.NullObject, err
	}
	return jServerCall, nil
}
开发者ID:vanadium,项目名称:go.jni,代码行数:10,代码来源:util.go

示例11: JavaBlessingPattern

// JavaBlessingPattern converts the provided Go BlessingPattern into Java
// BlessingPattern.
func JavaBlessingPattern(env jutil.Env, pattern security.BlessingPattern) (jutil.Object, error) {
	ref := jutil.GoNewRef(&pattern) // Un-refed when the Java BlessingRootsImpl is finalized.
	jPattern, err := jutil.NewObject(env, jBlessingPatternClass, []jutil.Sign{jutil.LongSign, jutil.StringSign}, int64(ref), string(pattern))
	if err != nil {
		jutil.GoDecRef(ref)
		return jutil.NullObject, err
	}
	return jPattern, nil
}
开发者ID:vanadium,项目名称:go.jni,代码行数:11,代码来源:util.go

示例12: JavaCall

// JavaCall converts the provided Go (security) Call into a Java Call object.
func JavaCall(env jutil.Env, call security.Call) (jutil.Object, error) {
	ref := jutil.GoNewRef(&call) // Un-refed when the Java CallImpl object is finalized.
	jCall, err := jutil.NewObject(env, jCallImplClass, []jutil.Sign{jutil.LongSign}, int64(ref))
	if err != nil {
		jutil.GoDecRef(ref)
		return jutil.NullObject, err
	}
	return jCall, nil
}
开发者ID:vanadium,项目名称:go.jni,代码行数:10,代码来源:call.go

示例13: JavaDiscovery

// JavaDiscovery converts a Go discovery instance into a Java discovery instance.
func JavaDiscovery(env jutil.Env, d discovery.T) (jutil.Object, error) {
	ref := jutil.GoNewRef(&d) // Un-refed when jDiscovery is finalized.
	jDiscovery, err := jutil.NewObject(env, jDiscoveryImplClass, []jutil.Sign{jutil.LongSign}, int64(ref))
	if err != nil {
		jutil.GoDecRef(ref)
		return jutil.NullObject, err
	}
	return jDiscovery, nil
}
开发者ID:vanadium,项目名称:go.jni,代码行数:10,代码来源:util.go

示例14: JavaBlessingRoots

// JavaBlessingRoots creates an instance of Java BlessingRoots that uses the provided Go
// BlessingRoots as its underlying implementation.
func JavaBlessingRoots(env jutil.Env, roots security.BlessingRoots) (jutil.Object, error) {
	ref := jutil.GoNewRef(&roots) // Un-refed when the Java BlessingRootsImpl is finalized.
	jRoots, err := jutil.NewObject(env, jBlessingRootsImplClass, []jutil.Sign{jutil.LongSign}, int64(ref))
	if err != nil {
		jutil.GoDecRef(ref)
		return jutil.NullObject, err
	}
	return jRoots, nil
}
开发者ID:vanadium,项目名称:go.jni,代码行数:11,代码来源:roots.go

示例15: JavaBlessingStore

// JavaBlessingStore creates an instance of Java BlessingStore that uses the provided Go
// BlessingStore as its underlying implementation.
func JavaBlessingStore(env jutil.Env, store security.BlessingStore) (jutil.Object, error) {
	ref := jutil.GoNewRef(&store) // Un-refed when the Java BlessingStoreImpl is finalized.
	jObj, err := jutil.NewObject(env, jBlessingStoreImplClass, []jutil.Sign{jutil.LongSign}, int64(ref))
	if err != nil {
		jutil.GoDecRef(ref)
		return jutil.NullObject, err
	}
	return jObj, nil
}
开发者ID:vanadium,项目名称:go.jni,代码行数:11,代码来源:store.go


注:本文中的v/io/x/jni/util.NewObject函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。