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); } }
@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); }
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; }
/** 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; }
@Override public Object fromNative(Object nativeValue, FromNativeContext context) { Object o = super.fromNative(nativeValue, context); if (InvalidHandle.equals(o)) { return InvalidHandle; } return o; }
@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); }
@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; }
@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); }
@Override public Object fromNative(Object nativeValue, FromNativeContext context) { // Always pass along null pointer values if (nativeValue == null) { return null; } setPointer((Pointer) nativeValue); return this; }
@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); }
/** 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; }
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; }
/** * 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; }
@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); } }
/** * 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; }
@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; }
@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; }
/** 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; }
@Override public Object fromNative(Object value, FromNativeContext context) { return ((Integer) value).intValue() != 0; }
@Override public Object fromNative(Object nativeValue, FromNativeContext context) { setPointer((Pointer) nativeValue); // Always pass along null pointer values return nativeValue == null ? null : this; }
public Object fromNative(Object arg, FromNativeContext arg1) { return ClockTime.valueOf((Long) arg, TimeUnit.NANOSECONDS); }
public Object fromNative(Object arg0, FromNativeContext arg1) { return Boolean.valueOf(((Integer)arg0).intValue() != 0); }
public Object fromNative(Object arg0, FromNativeContext arg1) { return new GQuark((Integer) arg0); }
public Object fromNative(Object arg0, FromNativeContext arg1) { return new IntPtr(((Number) arg0).intValue()); }
public Object fromNative(Object arg0, FromNativeContext arg1) { return QueryType.valueOf(((Number) arg0).intValue()); }
@Override public Object fromNative(Object nativeValue, FromNativeContext context) { return valueOf(((Number) nativeValue).longValue(), ""); }