@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); }