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

项目:gstreamer1.x-java    文件:GTypeMapper.java   
public Object fromNative(Object result, FromNativeContext context) {
    if (result == null) {
        return null;
    }
    if (context instanceof MethodResultContext) {
        MethodResultContext functionContext = (MethodResultContext) context;
        Method method = functionContext.getMethod();
        Pointer ptr = (Pointer) result;
        String s = ptr.getString(0);
        if (method.isAnnotationPresent(FreeReturnValue.class)
            || method.isAnnotationPresent(CallerOwnsReturn.class)) {
            GlibAPI.GLIB_API.g_free(ptr);
        }
        return s;
    } else {
        return ((Pointer) result).getString(0);
    }           
}
项目:gst1-java-core    文件:GTypeMapper.java   
public Object fromNative(Object result, FromNativeContext context) {
    if (result == null) {
        return null;
    }
    if (context instanceof MethodResultContext) {
        MethodResultContext functionContext = (MethodResultContext) context;
        Method method = functionContext.getMethod();
        Pointer ptr = (Pointer) result;
        String s = ptr.getString(0);
        if (method.isAnnotationPresent(FreeReturnValue.class)
            || method.isAnnotationPresent(CallerOwnsReturn.class)) {
            GlibAPI.GLIB_API.g_free(ptr);
        }
        return s;
    } else {
        return ((Pointer) result).getString(0);
    }           
}
项目:java-gobject    文件:GTypeMapper.java   
@SuppressWarnings(value = "unchecked")
public Object fromNative(Object result, FromNativeContext context) {
    if (result == null) {
        return null;
    }
    if (context instanceof FunctionResultContext) {
        return NativeObject.Internals.objectFor((Pointer) result, context.getTargetType(), true);
    }            
    if (context instanceof CallbackParameterContext || context instanceof StructureReadContext) {
        return NativeObject.Internals.objectFor((Pointer) result, context.getTargetType(), false);
    }
    if (context instanceof MethodResultContext) {
        throw new RuntimeException("Got illegal MethodResultContext in GTypeMapper");
    }            
    throw new IllegalStateException("Cannot convert to NativeObject from " + context);
}