static NativeType nativeType(jnr.ffi.Type jnrType) { return jnrType.getNativeType(); }
static NativeType nativeType(jnr.ffi.Type jnrType) { return jnrType.getNativeType(); }
static NativeType nativeType(jnr.ffi.Type jnrType) { return jnrType.getNativeType(); }
static NativeType getMethodResultNativeType(jnr.ffi.Runtime runtime, Class resultClass, Collection<Annotation> annotations) { return Types.getType(runtime, resultClass, annotations).getNativeType(); }
static NativeType getMethodResultNativeType(jnr.ffi.Runtime runtime, Class resultClass, Collection<Annotation> annotations) { return Types.getType(runtime, resultClass, annotations).getNativeType(); }
static NativeType getMethodParameterNativeType(jnr.ffi.Runtime runtime, Class parameterClass, Collection<Annotation> annotations) { return Types.getType(runtime, parameterClass, annotations).getNativeType(); }
static NativeType getMethodParameterNativeType(jnr.ffi.Runtime runtime, Class parameterClass, Collection<Annotation> annotations) { return Types.getType(runtime, parameterClass, annotations).getNativeType(); }
static NativeType getMethodParameterNativeType(jnr.ffi.Runtime runtime, Class parameterClass, Collection<Annotation> annotations) { return Types.getType(runtime, parameterClass, annotations).getNativeType(); }
static NativeType getMethodResultNativeType(jnr.ffi.Runtime runtime, Class resultClass, Collection<Annotation> annotations) { return Types.getType(runtime, resultClass, annotations).getNativeType(); }
@Override public long getInt(Type type, long offset) { switch (type.getNativeType()) { case SCHAR: case UCHAR: return getByte(offset); case SSHORT: case USHORT: return getShort(offset); case SINT: case UINT: return getInt(offset); case SLONG: case ULONG: return getNativeLong(offset); case SLONGLONG: case ULONGLONG: return getLongLong(offset); default: throw new IllegalArgumentException("unsupported integer type: " + type.getNativeType()); } }
@Override public long getInt(Type type, long offset) { switch (type.getNativeType()) { case SCHAR: case UCHAR: return getByte(offset); case SSHORT: case USHORT: return getShort(offset); case SINT: case UINT: return getInt(offset); case SLONG: case ULONG: return getNativeLong(offset); case SLONGLONG: case ULONGLONG: return getLongLong(offset); default: throw new IllegalArgumentException("unsupported integer type: " + type.getNativeType()); } }
@Override public void putInt(Type type, long offset, long value) { switch (type.getNativeType()) { case SCHAR: case UCHAR: putByte(offset, (byte) value); break; case SSHORT: case USHORT: putShort(offset, (short) value); break; case SINT: case UINT: putInt(offset, (int) value); break; case SLONG: case ULONG: putNativeLong(offset, value); break; case SLONGLONG: case ULONGLONG: putLongLong(offset, value); break; default: throw new IllegalArgumentException("unsupported integer type: " + type.getNativeType()); } }
@Override public long getInt(Type type, long offset) { switch (type.getNativeType()) { case SCHAR: case UCHAR: return getByte(offset); case SSHORT: case USHORT: return getShort(offset); case SINT: case UINT: return getInt(offset); case SLONG: case ULONG: return getNativeLong(offset); case SLONGLONG: case ULONGLONG: return getLongLong(offset); default: throw new IllegalArgumentException("unsupported integer type: " + type.getNativeType()); } }
static ToNativeType getResultType(jnr.ffi.Runtime runtime, Method m, SignatureTypeMapper typeMapper) { Collection<Annotation> annotations = sortedAnnotationCollection(m.getAnnotations()); ToNativeContext context = new SimpleNativeContext(runtime, annotations); SignatureType signatureType = DefaultSignatureType.create(m.getReturnType(), context); jnr.ffi.mapper.ToNativeType toNativeType = typeMapper.getToNativeType(signatureType, context); ToNativeConverter converter = toNativeType != null ? toNativeType.getToNativeConverter() : null; Class javaClass = converter != null ? converter.nativeType() : m.getReturnType(); NativeType nativeType = Types.getType(runtime, javaClass, annotations).getNativeType(); return new ToNativeType(m.getReturnType(), nativeType, annotations, converter, null); }
static jnr.ffi.provider.ToNativeType getResultType(jnr.ffi.Runtime runtime, Method m, SignatureTypeMapper typeMapper) { Collection<Annotation> annotations = sortedAnnotationCollection(m.getAnnotations()); ToNativeContext context = new SimpleNativeContext(runtime, annotations); SignatureType signatureType = DefaultSignatureType.create(m.getReturnType(), context); jnr.ffi.mapper.ToNativeType toNativeType = typeMapper.getToNativeType(signatureType, context); ToNativeConverter converter = toNativeType != null ? toNativeType.getToNativeConverter() : null; Class javaClass = converter != null ? converter.nativeType() : m.getReturnType(); NativeType nativeType = Types.getType(runtime, javaClass, annotations).getNativeType(); return new jnr.ffi.provider.ToNativeType(m.getReturnType(), nativeType, annotations, converter, null); }
static jnr.ffi.provider.ToNativeType getResultType(jnr.ffi.Runtime runtime, Method m, SignatureTypeMapper typeMapper) { Collection<Annotation> annotations = sortedAnnotationCollection(m.getAnnotations()); ToNativeContext context = new SimpleNativeContext(runtime, annotations); SignatureType signatureType = DefaultSignatureType.create(m.getReturnType(), context); jnr.ffi.mapper.ToNativeType toNativeType = typeMapper.getToNativeType(signatureType, context); ToNativeConverter converter = toNativeType != null ? toNativeType.getToNativeConverter() : null; Class javaClass = converter != null ? converter.nativeType() : m.getReturnType(); NativeType nativeType = Types.getType(runtime, javaClass, annotations).getNativeType(); return new jnr.ffi.provider.ToNativeType(m.getReturnType(), nativeType, annotations, converter, null); }
static FromNativeType getParameterType(jnr.ffi.Runtime runtime, Method m, int idx, SignatureTypeMapper typeMapper) { Collection<Annotation> annotations = sortedAnnotationCollection(m.getParameterAnnotations()[idx]); Class declaredJavaClass = m.getParameterTypes()[idx]; FromNativeContext context = new SimpleNativeContext(runtime, annotations); SignatureType signatureType = DefaultSignatureType.create(declaredJavaClass, context); jnr.ffi.mapper.FromNativeType fromNativeType = typeMapper.getFromNativeType(signatureType, context); FromNativeConverter converter = fromNativeType != null ? fromNativeType.getFromNativeConverter() : null; Class javaClass = converter != null ? converter.nativeType() : declaredJavaClass; NativeType nativeType = Types.getType(runtime, javaClass, annotations).getNativeType(); return new FromNativeType(declaredJavaClass, nativeType, annotations, converter, null); }
static jnr.ffi.provider.FromNativeType getParameterType(jnr.ffi.Runtime runtime, Method m, int idx, SignatureTypeMapper typeMapper) { Collection<Annotation> annotations = sortedAnnotationCollection(m.getParameterAnnotations()[idx]); Class declaredJavaClass = m.getParameterTypes()[idx]; FromNativeContext context = new SimpleNativeContext(runtime, annotations); SignatureType signatureType = DefaultSignatureType.create(declaredJavaClass, context); jnr.ffi.mapper.FromNativeType fromNativeType = typeMapper.getFromNativeType(signatureType, context); FromNativeConverter converter = fromNativeType != null ? fromNativeType.getFromNativeConverter() : null; Class javaClass = converter != null ? converter.nativeType() : declaredJavaClass; NativeType nativeType = Types.getType(runtime, javaClass, annotations).getNativeType(); return new jnr.ffi.provider.FromNativeType(declaredJavaClass, nativeType, annotations, converter, null); }
static jnr.ffi.provider.FromNativeType getParameterType(jnr.ffi.Runtime runtime, Method m, int idx, SignatureTypeMapper typeMapper) { Collection<Annotation> annotations = sortedAnnotationCollection(m.getParameterAnnotations()[idx]); Class declaredJavaClass = m.getParameterTypes()[idx]; FromNativeContext context = new SimpleNativeContext(runtime, annotations); SignatureType signatureType = DefaultSignatureType.create(declaredJavaClass, context); jnr.ffi.mapper.FromNativeType fromNativeType = typeMapper.getFromNativeType(signatureType, context); FromNativeConverter converter = fromNativeType != null ? fromNativeType.getFromNativeConverter() : null; Class javaClass = converter != null ? converter.nativeType() : declaredJavaClass; NativeType nativeType = Types.getType(runtime, javaClass, annotations).getNativeType(); return new jnr.ffi.provider.FromNativeType(declaredJavaClass, nativeType, annotations, converter, null); }
static Variable createVariableAccessor(jnr.ffi.Runtime runtime, Method method, long symbolAddress, SignatureTypeMapper typeMapper, Collection<Annotation> annotations) { java.lang.reflect.Type variableType = ((ParameterizedType) method.getGenericReturnType()).getActualTypeArguments()[0]; if (!(variableType instanceof Class)) { throw new IllegalArgumentException("unsupported variable class: " + variableType); } Class javaType = (Class) variableType; SimpleNativeContext context = new SimpleNativeContext(runtime, annotations); SignatureType signatureType = DefaultSignatureType.create(javaType, (FromNativeContext) context); jnr.ffi.mapper.FromNativeType mappedFromNativeType = typeMapper.getFromNativeType(signatureType, context); FromNativeConverter fromNativeConverter = mappedFromNativeType != null ? mappedFromNativeType.getFromNativeConverter() : null; jnr.ffi.mapper.ToNativeType mappedToNativeType = typeMapper.getToNativeType(signatureType, context); ToNativeConverter toNativeConverter = mappedToNativeType != null ? mappedToNativeType.getToNativeConverter() : null; Class boxedType = toNativeConverter != null ? toNativeConverter.nativeType() : javaType; NativeType nativeType = Types.getType(runtime, boxedType, annotations).getNativeType(); jnr.ffi.provider.ToNativeType toNativeType = new jnr.ffi.provider.ToNativeType(javaType, nativeType, annotations, toNativeConverter, null); jnr.ffi.provider.FromNativeType fromNativeType = new jnr.ffi.provider.FromNativeType(javaType, nativeType, annotations, fromNativeConverter, null); Variable variable; Pointer memory = MemoryUtil.newPointer(runtime, symbolAddress); variable = getNativeVariableAccessor(memory, toNativeType, fromNativeType); return toNativeType.getToNativeConverter() != null ? getConvertingVariable(variable, toNativeType.getToNativeConverter(), fromNativeType.getFromNativeConverter()) : variable; }