private static Class<?> nativeType(Class<?> cls) { return NativeMappedConverter.getInstance(cls).nativeType(); } // Called from native code
/** Override this to handle any custom class mappings. * @param cls Java class of a parameter * @return number of native bytes used for this class on the stack */ protected int getArgumentNativeStackSize(Class<?> cls) { if (NativeMapped.class.isAssignableFrom(cls)) { cls = NativeMappedConverter.getInstance(cls).nativeType(); } if (cls.isArray()) { return Native.POINTER_SIZE; } try { return Native.getNativeSize(cls); } catch(IllegalArgumentException e) { throw new IllegalArgumentException("Unknown native stack allocation size for " + cls); } }
private Class<?> getNativeType(Class<?> cls) { if (Structure.class.isAssignableFrom(cls)) { // Make sure we can instantiate an argument of this type Structure.validate((Class<? extends Structure>)cls); if (!Structure.ByValue.class.isAssignableFrom(cls)) return Pointer.class; } else if (NativeMapped.class.isAssignableFrom(cls)) { return NativeMappedConverter.getInstance(cls).nativeType(); } else if (cls == String.class || cls == WString.class || cls == String[].class || cls == WString[].class || Callback.class.isAssignableFrom(cls)) { return Pointer.class; } return cls; }
cls = NativeMappedConverter.getInstance(cls).nativeType();
Class<?> nativeType = NativeMappedConverter.getInstance(type).nativeType(); if (nativeType == String.class) { return CVT_NATIVE_MAPPED_STRING;
if (NativeMapped.class.isAssignableFrom(type)) { NativeMappedConverter tc = NativeMappedConverter.getInstance(type); type = tc.nativeType(); value = tc.toNative(value, new ToNativeContext());
if (NativeMapped.class.isAssignableFrom(type)) { NativeMappedConverter tc = NativeMappedConverter.getInstance(type); nativeType = tc.nativeType(); structField.writeConverter = tc; structField.readConverter = tc;
return get(c.toNative(obj, new ToNativeContext()), c.nativeType());
NativeMappedConverter tc = NativeMappedConverter.getInstance(returnType); resultConverter = tc; nativeReturnType = tc.nativeType(); } else if (mapper != null) { resultConverter = mapper.getFromNativeConverter(returnType);
} else if (NativeMapped.class.isAssignableFrom(type)) { NativeMappedConverter tc = NativeMappedConverter.getInstance(type); Class<?> nativeType = tc.nativeType(); setValue(offset, tc.toNative(value, new ToNativeContext()), nativeType); } else if (type.isArray()) {
case CVT_POINTER_TYPE: closure_rtype = FFIType.get(Pointer.class).peer; rtype = FFIType.get(NativeMappedConverter.getInstance(rclass).nativeType()).peer; break; case CVT_STRUCTURE: || (conversionType == CVT_NATIVE_MAPPED_WSTRING) || (conversionType == CVT_INTEGER_TYPE)) { type = NativeMappedConverter.getInstance(type).nativeType(); } else if ((conversionType == CVT_TYPE_MAPPER) || (conversionType == CVT_TYPE_MAPPER_STRING)
Object value = getValue(offset, tc.nativeType(), null); result = tc.fromNative(value, new FromNativeContext(type));
int size = Native.getNativeSize(result.getClass(), result) / array.length; for (int i=0;i < array.length;i++) { Object value = getValue(offset + size*i, tc.nativeType(), array[i]); array[i] = (NativeMapped)tc.fromNative(value, new FromNativeContext(cls));
NativeMapped[] buf = (NativeMapped[])value; NativeMappedConverter tc = NativeMappedConverter.getInstance(cls); Class<?> nativeType = tc.nativeType(); int size = Native.getNativeSize(value.getClass(), value) / buf.length; for (int i=0;i < buf.length;i++) {
private static Class<?> nativeType(Class<?> cls) { return NativeMappedConverter.getInstance(cls).nativeType(); } // Called from native code
/** Override this to handle any custom class mappings. */ protected int getArgumentNativeStackSize(Class cls) { if (NativeMapped.class.isAssignableFrom(cls)) { cls = new NativeMappedConverter(cls).nativeType(); } if (cls.isArray()) { return Pointer.SIZE; } try { return Native.getNativeSize(cls); } catch(IllegalArgumentException e) { throw new IllegalArgumentException("Unknown native stack allocation size for " + cls); } } /** Convert the given Java method into a decorated stdcall name,
private Class getNativeType(Class cls) { if (Structure.class.isAssignableFrom(cls)) { // Make sure we can instantiate an argument of this type Structure.newInstance(cls); if (!Structure.ByValue.class.isAssignableFrom(cls)) return Pointer.class; } else if (NativeMapped.class.isAssignableFrom(cls)) { return new NativeMappedConverter(cls).nativeType(); } else if (cls == String.class || cls == WString.class || Callback.class.isAssignableFrom(cls)) { return Pointer.class; } return cls; }
private Class<?> getNativeType(Class<?> cls) { if (Structure.class.isAssignableFrom(cls)) { // Make sure we can instantiate an argument of this type Structure.validate(cls); if (!Structure.ByValue.class.isAssignableFrom(cls)) return Pointer.class; } else if (NativeMapped.class.isAssignableFrom(cls)) { return NativeMappedConverter.getInstance(cls).nativeType(); } else if (cls == String.class || cls == WString.class || cls == String[].class || cls == WString[].class || Callback.class.isAssignableFrom(cls)) { return Pointer.class; } return cls; }
/** Override this to handle any custom class mappings. * @param cls Java class of a parameter * @return number of native bytes used for this class on the stack */ protected int getArgumentNativeStackSize(Class<?> cls) { if (NativeMapped.class.isAssignableFrom(cls)) { cls = NativeMappedConverter.getInstance(cls).nativeType(); } if (cls.isArray()) { return Pointer.SIZE; } try { return Native.getNativeSize(cls); } catch(IllegalArgumentException e) { throw new IllegalArgumentException("Unknown native stack allocation size for " + cls); } }
cls = new NativeMappedConverter(cls).nativeType();