本文整理汇总了Golang中v/io/x/jni/util.GoDecRef函数的典型用法代码示例。如果您正苦于以下问题:Golang GoDecRef函数的具体用法?Golang GoDecRef怎么用?Golang GoDecRef使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GoDecRef函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Java_io_v_v23_context_VContext_nativeFinalize
//export Java_io_v_v23_context_VContext_nativeFinalize
func Java_io_v_v23_context_VContext_nativeFinalize(jenv *C.JNIEnv, jVContext C.jobject, goRef C.jlong, goCancelRef C.jlong) {
jutil.GoDecRef(jutil.Ref(goRef))
if jutil.Ref(goCancelRef) != jutil.NullRef {
jutil.GoDecRef(jutil.Ref(goCancelRef))
}
}
示例2: Lookup
func (d *dispatcher) Lookup(ctx *context.T, suffix string) (interface{}, security.Authorizer, error) {
// Get Java environment.
env, freeFunc := jutil.GetEnv()
defer freeFunc()
result, err := jutil.CallStaticLongArrayMethod(env, jServerRPCHelperClass, "lookup", []jutil.Sign{dispatcherSign, jutil.StringSign}, d.jDispatcher, suffix)
if err != nil {
return nil, nil, fmt.Errorf("error invoking Java dispatcher's lookup() method: %v", err)
}
if result == nil {
// Lookup returned null, which means that the dispatcher isn't handling the object -
// this is not an error.
return nil, nil, nil
}
if len(result) != 2 {
return nil, nil, fmt.Errorf("lookup returned %d elems, want 2", len(result))
}
invoker := *(*rpc.Invoker)(jutil.GoRefValue(jutil.Ref(result[0])))
jutil.GoDecRef(jutil.Ref(result[0]))
authorizer := security.Authorizer(nil)
if result[1] != 0 {
authorizer = *(*security.Authorizer)(jutil.GoRefValue(jutil.Ref(result[1])))
jutil.GoDecRef(jutil.Ref(result[1]))
}
return invoker, authorizer, nil
}
示例3: JavaContext
// JavaContext converts the provided Go Context into a Java VContext.
// If the provided cancel function is nil, Java VContext won't be
// cancelable.
func JavaContext(env jutil.Env, ctx *context.T, cancel context.CancelFunc) (jutil.Object, error) {
ctxRef := jutil.GoNewRef(ctx) // Un-refed when the Java context object is finalized.
cancelRef := jutil.NullRef
if cancel != nil {
cancelRef = jutil.GoNewRef(&cancel) // Un-refed when the Java context object is finalized.
}
jCtx, err := jutil.NewObject(env, jVContextClass, []jutil.Sign{jutil.LongSign, jutil.LongSign}, int64(ctxRef), int64(cancelRef))
if err != nil {
jutil.GoDecRef(ctxRef)
if cancel != nil {
jutil.GoDecRef(cancelRef)
}
return jutil.NullObject, err
}
return jCtx, err
}
示例4: 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))
}
示例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))
}
示例6: 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))
}
示例7: JavaOutputChannel
// JavaOutputChannel creates a new Java OutputChannel object given the provided Go convert, send
// and close functions. Send is invoked with the result of convert, which must be non-blocking.
func JavaOutputChannel(env jutil.Env, ctx *context.T, ctxCancel func(), convert func(jutil.Object) (interface{}, error), send func(interface{}) error, close func() error) (jutil.Object, error) {
jContext, err := jcontext.JavaContext(env, ctx, ctxCancel)
if err != nil {
return jutil.NullObject, err
}
convertRef := jutil.GoNewRef(&convert) // Un-refed when jOutputChannel is finalized.
sendRef := jutil.GoNewRef(&send) // Un-refed when jOutputChannel is finalized.
closeRef := jutil.GoNewRef(&close) // Un-refed when jOutputChannel is finalized.
jOutputChannel, err := jutil.NewObject(env, jOutputChannelImplClass, []jutil.Sign{contextSign, jutil.LongSign, jutil.LongSign, jutil.LongSign}, jContext, int64(convertRef), int64(sendRef), int64(closeRef))
if err != nil {
jutil.GoDecRef(convertRef)
jutil.GoDecRef(sendRef)
jutil.GoDecRef(closeRef)
return jutil.NullObject, err
}
return jOutputChannel, nil
}
示例8: StartScan
func (d *driver) StartScan(uuids []string, baseUuid, maskUuid string, handler ble.ScanHandler) error {
env, freeFunc := jutil.GetEnv()
defer freeFunc()
handlerRef := jutil.GoNewRef(&handler) // Un-refed when jNativeScanHandler is finalized.
jNativeScanHandler, err := jutil.NewObject(env, jNativeScanHandlerClass, []jutil.Sign{jutil.LongSign}, int64(handlerRef))
if err != nil {
jutil.GoDecRef(handlerRef)
return err
}
err = jutil.CallVoidMethod(env, d.jDriver, "startScan", []jutil.Sign{jutil.ArraySign(jutil.StringSign), jutil.StringSign, jutil.StringSign, scanHandlerSign}, uuids, baseUuid, maskUuid, jNativeScanHandler)
if err != nil {
jutil.GoDecRef(handlerRef)
return err
}
return nil
}
示例9: 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
}
示例10: 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
}
示例11: 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
}
示例12: 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
}
示例13: 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
}
示例14: 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
}
示例15: 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
}