Java 类com.sun.jna.MethodParameterContext 实例源码

项目:gstreamer1.x-java    文件:GTypeMapper.java   
public Object toNative(Object arg, ToNativeContext context) {
    if (arg == null) {
        return null;
    }
    Pointer ptr = ((NativeObject) arg).handle();

    //
    // Deal with any adjustments to the proxy neccessitated by gstreamer
    // breaking their reference-counting idiom with special cases
    //
    if (context instanceof MethodParameterContext) {
        MethodParameterContext mcontext = (MethodParameterContext) context;
        Method method = mcontext.getMethod();
        int index = mcontext.getParameterIndex();
        Annotation[][] parameterAnnotations = method.getParameterAnnotations();
        if (index < parameterAnnotations.length) {
            Annotation[] annotations = parameterAnnotations[index];
            for (int i = 0; i < annotations.length; ++i) {
                if (annotations[i] instanceof Invalidate) {
                    ((Handle) arg).invalidate();
                    break;
                } else if (annotations[i] instanceof IncRef) {
                    ((RefCountedObject) arg).ref();
                    break;
                }
            }
        }
    }
    return ptr;
}
项目:gst1-java-core    文件:GTypeMapper.java   
public Object toNative(Object arg, ToNativeContext context) {
    if (arg == null) {
        return null;
    }
    Pointer ptr = ((NativeObject) arg).handle();

    //
    // Deal with any adjustments to the proxy neccessitated by gstreamer
    // breaking their reference-counting idiom with special cases
    //
    if (context instanceof MethodParameterContext) {
        MethodParameterContext mcontext = (MethodParameterContext) context;
        Method method = mcontext.getMethod();
        int index = mcontext.getParameterIndex();
        Annotation[][] parameterAnnotations = method.getParameterAnnotations();
        if (index < parameterAnnotations.length) {
            Annotation[] annotations = parameterAnnotations[index];
            for (int i = 0; i < annotations.length; ++i) {
                if (annotations[i] instanceof Invalidate) {
                    ((Handle) arg).invalidate();
                    break;
                } else if (annotations[i] instanceof IncRef) {
                    ((RefCountedObject) arg).ref();
                    break;
                }
            }
        }
    }
    return ptr;
}