/** Performs auto-read only if uninitialized. */ void conditionalAutoRead() { if (!readCalled) { autoRead(); } }
public void autoRead() { if (getAutoRead()) { read(); if (array != null) { for (int i=1;i < array.length;i++) { array[i].autoRead(); } } } }
/** 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; }
Native.invokeStructure(this, this.peer, callFlags, args, Structure.newInstance((Class<? extends Structure>)returnType)); s.autoRead(); result = s; } else {
/** Performs auto-read only if uninitialized. */ void conditionalAutoRead() { if (!readCalled) { autoRead(); } }
public void autoRead() { if (getAutoRead()) { read(); if (array != null) { for (int i=1;i < array.length;i++) { array[i].autoRead(); } } } }
/** 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; }
@Test(enabled=false) public void testReadConfEnv() { LibLsf.config_param[] configParams = (LibLsf.config_param[]) new LibLsf.config_param().toArray(4); configParams[0].paramName = "LSF_UNIT_FOR_LIMITS"; configParams[1].paramName = "LSF_CONFDIR"; configParams[2].paramName = "MADE_UP_PARAMETER"; Structure.autoWrite(configParams); if (LibLsf.ls_readconfenv(configParams[0], null) != 0) { Assert.fail(LibLsf.ls_sysmsg()); } Structure.autoRead(configParams); System.out.println("LSF_UNIT_FOR_LIMITS: " + configParams[0].paramValue); Assert.assertNotNull(configParams[1].paramValue); Assert.assertNull(configParams[2].paramValue); Assert.assertNull(configParams[3].paramName); Assert.assertNull(configParams[3].paramValue); }
Native.invokeStructure(this, this.peer, callFlags, args, Structure.newInstance(returnType)); s.autoRead(); result = s; } else {