/** Called from native code only; same as {@link * #newInstance(Class,Pointer)}, except that it additionally calls * {@link #conditionalAutoRead()}. */ private static <T extends Structure> T newInstance(Class<T> type, long init) { try { T s = newInstance(type, init == 0 ? PLACEHOLDER_MEMORY : new Pointer(init)); if (init != 0) { s.conditionalAutoRead(); } return s; } catch(Throwable e) { LOG.log(Level.WARNING, "JNA: Error creating structure", e); return null; } }
/** Only keep the original structure if its native address is unchanged. * Otherwise replace it with a new object. * @param type Structure subclass * @param s Original Structure object * @param address the native <code>struct *</code> * @return Updated <code>Structure.ByReference</code> object */ static <T extends Structure> T updateStructureByReference(Class<T> type, T s, Pointer address) { if (address == null) { s = null; } else { if (s == null || !address.equals(s.getPointer())) { Structure s1 = reading().get(address); if (s1 != null && type.equals(s1.getClass())) { s = (T) s1; s.autoRead(); } else { s = newInstance(type, address); s.conditionalAutoRead(); } } else { s.autoRead(); } } return s; }
for (int i=1;i < array.length;i++) { array[i] = newInstance(getClass(), memory.share(i*size, size)); array[i].conditionalAutoRead();
if (result != null) { Structure s = Structure.newInstance((Class<? extends Structure>)returnType, (Pointer)result); s.conditionalAutoRead(); result = s;
} else { Structure s = Structure.newInstance((Class<? extends Structure>) dstType, (Pointer)value); s.conditionalAutoRead(); value = s;
if (first == null) { first = Structure.newInstance((Class<Structure>) cls, share(offset)); first.conditionalAutoRead(); sarray[0] = first;
/** Called from native code only; same as {@link * #newInstance(Class,Pointer)}, except that it additionally calls * {@link #conditionalAutoRead()}. */ private static Structure newInstance(Class<?> type, long init) { try { Structure s = newInstance(type, init == 0 ? PLACEHOLDER_MEMORY : new Pointer(init)); if (init != 0) { s.conditionalAutoRead(); } return s; } catch(Throwable e) { System.err.println("JNA: Error creating structure: " + e); return null; } }
/** Only keep the original structure if its native address is unchanged. * Otherwise replace it with a new object. * @param type Structure subclass * @param s Original Structure object * @param address the native <code>struct *</code> * @return Updated <code>Structure.ByReference</code> object */ static Structure updateStructureByReference(Class<?> type, Structure s, Pointer address) { if (address == null) { s = null; } else { if (s == null || !address.equals(s.getPointer())) { Structure s1 = reading().get(address); if (s1 != null && type.equals(s1.getClass())) { s = s1; s.autoRead(); } else { s = newInstance(type, address); s.conditionalAutoRead(); } } else { s.autoRead(); } } return s; }
} else { Structure s = Structure.newInstance(dstType, (Pointer)value); s.conditionalAutoRead(); value = s;
if (result != null) { Structure s = Structure.newInstance(returnType, (Pointer)result); s.conditionalAutoRead(); result = s;
for (int i=1;i < array.length;i++) { array[i] = newInstance(getClass(), memory.share(i*size, size)); array[i].conditionalAutoRead();
if (first == null) { first = Structure.newInstance(cls, share(offset)); first.conditionalAutoRead(); sarray[0] = first;