public static Struct newStruct(Type... fields) { List<Type> fieldsList = Arrays.asList(fields); StructReference ref = structCache.get(fieldsList); Struct s = ref != null ? ref.get() : null; if (s != null) { return s; } // Cull any dead references while ((ref = (StructReference) structReferenceQueue.poll()) != null) { structCache.remove(ref.fieldsList); } structCache.put(fieldsList, new StructReference(s = new Struct(Foreign.getInstance(), fields), structReferenceQueue, fieldsList)); return s; }
public static Struct newStruct(Type... fields) { List<Type> fieldsList = Arrays.asList(fields); StructReference ref = structCache.get(fieldsList); Struct s = ref != null ? ref.get() : null; if (s != null) { return s; } // Cull any dead references while ((ref = (StructReference) structReferenceQueue.poll()) != null) { structCache.remove(ref.fieldsList); } structCache.put(fieldsList, new StructReference(s = new Struct(Foreign.getInstance(), fields), structReferenceQueue, fieldsList)); return s; }
public static Struct newStruct(Type... fields) { List<Type> fieldsList = Arrays.asList(fields); StructReference ref = structCache.get(fieldsList); Struct s = ref != null ? ref.get() : null; if (s != null) { return s; } // Cull any dead references while ((ref = (StructReference) structReferenceQueue.poll()) != null) { structCache.remove(ref.fieldsList); } structCache.put(fieldsList, new StructReference(s = new Struct(Foreign.getInstance(), fields), structReferenceQueue, fieldsList)); return s; }
public static final StructLayout newStructLayout(Field[] fields, boolean isUnion) { com.kenai.jffi.Type[] fieldTypes = new com.kenai.jffi.Type[fields.length]; for (int i = 0; i < fields.length; ++i) { fieldTypes[i] = Util.jffiType(fields[i].ctype); } com.kenai.jffi.Type jffiType = isUnion ? new com.kenai.jffi.Union(fieldTypes) : new com.kenai.jffi.Struct(fieldTypes); return new StructLayout(fields, jffiType, MemoryOp.INVALID); } }