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

项目: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);
}
项目:jpraat    文件:NativeEnumConverter.java   
public Object fromNative(Object obj, FromNativeContext ctx) {
    final Integer nativeVal = (Integer) obj;
    final Class<?> targetClazz = ctx.getTargetType();
    Object retVal = null;
    if(targetClazz != null && 
            NativeEnum.class.isAssignableFrom(targetClazz)) {
        final Object[] enumVals = targetClazz.getEnumConstants();
        for(Object enumVal:enumVals) {
            final NativeEnum ne = (NativeEnum)enumVal;
            if(ne.getNativeValue() == nativeVal) {
                retVal = ne;
                break;
            }
        }
    }
    return retVal;
}
项目:incubator-netbeans    文件:WindowsNotifier.java   
/** Override to the appropriate object for INVALID_HANDLE_VALUE. */
@Override
public Object fromNative(Object nativeValue, FromNativeContext context) {
    Object o = super.fromNative(nativeValue, context);
    if (INVALID_HANDLE_VALUE.equals(o))
        return INVALID_HANDLE_VALUE;
    return o;
}
项目:incubator-netbeans    文件:Win32APISupport.java   
@Override
public Object fromNative(Object nativeValue, FromNativeContext context) {
    Object o = super.fromNative(nativeValue, context);
    if (InvalidHandle.equals(o)) {
        return InvalidHandle;
    }
    return o;
}
项目:DigitalMediaServer    文件:JnaLongEnumConverter.java   
@Override
public Object fromNative(Object input, FromNativeContext context) {
    if (!JnaLongEnum.class.isAssignableFrom(context.getTargetType())) {
        throw new IllegalStateException("JnaLongEnumConverter can only convert objects implementing JnaLongEnum");
    }
    @SuppressWarnings("rawtypes")
    Class targetClass = context.getTargetType();
    Object[] enumValues = targetClass.getEnumConstants();
    return ((JnaLongEnum<?>) enumValues[0]).typeForValue((long) input);
}
项目:DigitalMediaServer    文件:FixedArrayByReference.java   
@Override
public Object fromNative(Object nativeValue, FromNativeContext context) {
    // Always pass along null pointer values
    if (nativeValue == null) {
        return null;
    }
    super.setPointer((Pointer) nativeValue);
    return this;
}
项目:DigitalMediaServer    文件:KernReturnTConverter.java   
@Override
public Object fromNative(Object input, FromNativeContext context) {
    if (!KernReturnT.class.isAssignableFrom(context.getTargetType())) {
        throw new IllegalStateException(
            "KernReturnTConverter can only convert objects implementing KernReturnT"
        );
    }
    return DefaultKernReturnT.typeOf((int) input);
}
项目:DigitalMediaServer    文件:WStringByReference.java   
@Override
public Object fromNative(Object nativeValue, FromNativeContext context) {
    // Always pass along null pointer values
    if (nativeValue == null) {
        return null;
    }
    setPointer((Pointer) nativeValue);
    return this;
}
项目:DigitalMediaServer    文件:JnaIntEnumConverter.java   
@Override
public Object fromNative(Object input, FromNativeContext context) {
    if (!JnaIntEnum.class.isAssignableFrom(context.getTargetType())) {
        throw new IllegalStateException("JnaIntEnumConverter can only convert objects implementing JnaIntEnum");
    }
    @SuppressWarnings("rawtypes")
    Class targetClass = context.getTargetType();
    Object[] enumValues = targetClass.getEnumConstants();
    return ((JnaIntEnum<?>) enumValues[0]).typeForValue((int) input);
}
项目:DigitalMediaServer    文件:ArrayByReference.java   
@Override
public Object fromNative(Object nativeValue, FromNativeContext context) {
    // Always pass along null pointer values
    if (nativeValue == null) {
        return null;
    }
    super.setPointer((Pointer) nativeValue);
    return this;
}
项目:DigitalMediaServer    文件:UTF16StringByReference.java   
@Override
public Object fromNative(Object nativeValue, FromNativeContext context) {
    // Always pass along null pointer values
    if (nativeValue == null) {
        return null;
    }
    setPointer((Pointer) nativeValue);
    return this;
}
项目:DigitalMediaServer    文件:StringByReference.java   
@Override
public Object fromNative(Object nativeValue, FromNativeContext context) {
    // Always pass along null pointer values
    if (nativeValue == null) {
        return null;
    }
    setPointer((Pointer) nativeValue);
    return this;
}
项目:intellij-ce-playground    文件:W32API.java   
/** Override to the appropriate object for INVALID_HANDLE_VALUE. */
public Object fromNative(Object nativeValue, FromNativeContext context) {
    Object o = super.fromNative(nativeValue, context);
    if (INVALID_HANDLE_VALUE.equals(o))
        return INVALID_HANDLE_VALUE;
    return o;
}
项目:FoxTelem    文件:Kernel32Library.java   
public Object fromNative(Object nativeValue, FromNativeContext context) {
    Object o = super.fromNative(nativeValue, context);
    if (SetUpApiLibrary.NULL.equals(o))
        return SetUpApiLibrary.NULL;
    if (SetUpApiLibrary.INVALID_HANDLE_VALUE.equals(o))
        return SetUpApiLibrary.INVALID_HANDLE_VALUE;
    return o;
}
项目:javactivex    文件:WinNT.java   
/**
 * Override to the appropriate object for INVALID_HANDLE_VALUE.
 *
 * @param nativeValue
 * @param context
 * @return
 */
@Override
public Object fromNative(Object nativeValue, FromNativeContext context) {
    Object o = super.fromNative(nativeValue, context);
    if (WinBase.INVALID_HANDLE_VALUE.equals(o)) {
        return WinBase.INVALID_HANDLE_VALUE;
    }
    return o;
}
项目:java-gobject    文件:GFlags.java   
@SuppressWarnings("unchecked")
public final Object fromNative(Object nativeValue, FromNativeContext context) {
    try {
        return context.getTargetType().getConstructor(new Class<?>[] { int[].class })
            .newInstance(new Object[] { new int[] { (Integer) nativeValue } });
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
项目:jpexs-decompiler    文件:WinNT.java   
/**
 * Override to the appropriate object for INVALID_HANDLE_VALUE.
 *
 * @param nativeValue nativeValue
 * @param context context
 * @return result
 */
@Override
public Object fromNative(Object nativeValue, FromNativeContext context) {
    Object o = super.fromNative(nativeValue, context);
    if (WinBase.INVALID_HANDLE_VALUE.equals(o)) {
        return WinBase.INVALID_HANDLE_VALUE;
    }
    return o;
}
项目:tools-idea    文件:W32API.java   
/** Override to the appropriate object for INVALID_HANDLE_VALUE. */
public Object fromNative(Object nativeValue, FromNativeContext context) {
    Object o = super.fromNative(nativeValue, context);
    if (INVALID_HANDLE_VALUE.equals(o))
        return INVALID_HANDLE_VALUE;
    return o;
}
项目:testgrid    文件:W32API.java   
@Override
public Object fromNative(Object nativeValue, FromNativeContext context) {
    Object o = super.fromNative(nativeValue, context);
    if (INVALID_HANDLE_VALUE.equals(o))
        return INVALID_HANDLE_VALUE;
    return o;
}
项目:purejavahidapi    文件:WinDef.java   
@Override
public Object fromNative(Object nativeValue, FromNativeContext context) {
    Object o = super.fromNative(nativeValue, context);
    if (INVALID_HANDLE_VALUE.equals(o)) {
        return INVALID_HANDLE_VALUE;
    }
    return o;
}
项目:NuProcess    文件:NuWinNT.java   
@Override
public Object fromNative(Object nativeValue, FromNativeContext context)
{
   Object o = super.fromNative(nativeValue, context);
   if (INVALID_HANDLE_VALUE.equals(o)) {
      return INVALID_HANDLE_VALUE;
   }
   return o;
}
项目:process    文件:Win32.java   
/** Override to the appropriate object for INVALID_HANDLE_VALUE. */
public Object fromNative(Object nativeValue, FromNativeContext context) {
  Object o = super.fromNative(nativeValue, context);
  if (INVALID_HANDLE_VALUE.equals(o)) {
    return INVALID_HANDLE_VALUE;
  }
  return o;
}
项目:schedulix    文件:W32API.java   
@Override
public Object fromNative(Object nativeValue, FromNativeContext context)
{
    Object o = super.fromNative(nativeValue, context);
    if (INVALID_HANDLE_VALUE.equals(o))
        return INVALID_HANDLE_VALUE;
    return o;
}
项目:consulo    文件:W32API.java   
/** Override to the appropriate object for INVALID_HANDLE_VALUE. */
public Object fromNative(Object nativeValue, FromNativeContext context) {
    Object o = super.fromNative(nativeValue, context);
    if (INVALID_HANDLE_VALUE.equals(o))
        return INVALID_HANDLE_VALUE;
    return o;
}
项目:cohorte-utilities    文件:W32API.java   
@Override
public Object fromNative(Object nativeValue, FromNativeContext context) {
    Object o = super.fromNative(nativeValue, context);
    if (INVALID_HANDLE_VALUE.equals(o))
        return INVALID_HANDLE_VALUE;
    return o;
}
项目:carina    文件:W32API.java   
@Override
public Object fromNative(Object nativeValue, FromNativeContext context) {
    Object o = super.fromNative(nativeValue, context);
    if (INVALID_HANDLE_VALUE.equals(o))
        return INVALID_HANDLE_VALUE;
    return o;
}
项目:incubator-netbeans    文件:GnomeKeyringLibrary.java   
@Override public Object fromNative(Object value, FromNativeContext context) {
    return ((Integer) value).intValue() != 0;
}
项目:DigitalMediaServer    文件:TerminatedArray.java   
@Override
public Object fromNative(Object nativeValue, FromNativeContext context) {
    setPointer((Pointer) nativeValue);
    // Always pass along null pointer values
    return nativeValue == null ? null : this;
}
项目:gstreamer1.x-java    文件:GTypeMapper.java   
public Object fromNative(Object arg, FromNativeContext arg1) {
    return ClockTime.valueOf((Long) arg, TimeUnit.NANOSECONDS);
}
项目:gstreamer1.x-java    文件:GTypeMapper.java   
public Object fromNative(Object arg0, FromNativeContext arg1) {
    return Boolean.valueOf(((Integer)arg0).intValue() != 0);
}
项目:gstreamer1.x-java    文件:GTypeMapper.java   
public Object fromNative(Object arg0, FromNativeContext arg1) {
    return new GQuark((Integer) arg0);
}
项目:gstreamer1.x-java    文件:GTypeMapper.java   
public Object fromNative(Object arg0, FromNativeContext arg1) {
    return new IntPtr(((Number) arg0).intValue());            
}
项目:gstreamer1.x-java    文件:GTypeMapper.java   
public Object fromNative(Object arg0, FromNativeContext arg1) {
    return QueryType.valueOf(((Number) arg0).intValue());            
}
项目:gstreamer1.x-java    文件:GType.java   
@Override
public Object fromNative(Object nativeValue, FromNativeContext context) {
    return valueOf(((Number) nativeValue).longValue(), "");
}
项目:gst1-java-core    文件:GTypeMapper.java   
public Object fromNative(Object arg, FromNativeContext arg1) {
    return ClockTime.valueOf((Long) arg, TimeUnit.NANOSECONDS);
}
项目:gst1-java-core    文件:GTypeMapper.java   
public Object fromNative(Object arg0, FromNativeContext arg1) {
    return Boolean.valueOf(((Integer)arg0).intValue() != 0);
}
项目:gst1-java-core    文件:GTypeMapper.java   
public Object fromNative(Object arg0, FromNativeContext arg1) {
    return new GQuark((Integer) arg0);
}
项目:gst1-java-core    文件:GTypeMapper.java   
public Object fromNative(Object arg0, FromNativeContext arg1) {
    return new IntPtr(((Number) arg0).intValue());            
}