public AbstractRuntime(ByteOrder byteOrder, EnumMap<NativeType, Type> typeMap) { this.byteOrder = byteOrder; EnumSet<NativeType> nativeTypes = EnumSet.allOf(NativeType.class); types = new Type[nativeTypes.size()]; for (NativeType t : nativeTypes) { types[t.ordinal()] = typeMap.containsKey(t) ? typeMap.get(t) : new BadType(t.toString()); } this.addressSize = types[NativeType.ADDRESS.ordinal()].size(); this.longSize = types[NativeType.SLONG.ordinal()].size(); this.addressMask = addressSize == 4 ? 0xffffffffL : 0xffffffffffffffffL; }
/** * Gets the size of a Pointer in bits * * @return the size of the Pointer */ public final int size() { return getRuntime().findType(NativeType.ADDRESS).size() * 8; }
/** * Gets the size of a Pointer in bits * * @return the size of the Pointer */ public final int size() { return getRuntime().findType(NativeType.ADDRESS).size(); }
/** * Gets the size of a Pointer in bits * * @return the size of the Pointer */ public final int size() { return getRuntime().findType(NativeType.ADDRESS).size() * 8; }
/** * Gets the size of a Pointer in bits * * @return the size of the Pointer */ public final int size() { return getRuntime().findType(NativeType.ADDRESS).size() * 8; }
/** * Allocates a new block of java memory and wraps it in a {@link Pointer} * accessor. * * @param runtime The current runtime. * @param type The type to allocate memory for. * * @return a {@code Pointer} instance that can access the memory. */ public static Pointer allocate(Runtime runtime, Type type) { return runtime.getMemoryManager().allocate(type.size()); }
/** * Allocates a new block of java memory and wraps it in a {@link Pointer} * accessor. * * @param type The type to allocate memory for. * * @return a {@code Pointer} instance that can access the memory. */ public static Pointer allocate(Runtime runtime, Type type) { return runtime.getMemoryManager().allocate(type.size()); }
/** * Allocates a new block of java memory and wraps it in a {@link Pointer} * accessor. * * @param runtime The current runtime. * @param type The native type to allocate memory for. * * @return a {@code Pointer} instance that can access the memory. */ public static Pointer allocate(Runtime runtime, NativeType type) { return runtime.getMemoryManager().allocate(runtime.findType(type).size()); }
/** * Allocates a new block of java memory and wraps it in a {@link Pointer} * accessor. * * @param type The native type to allocate memory for. * * @return a {@code Pointer} instance that can access the memory. */ public static Pointer allocate(Runtime runtime, NativeType type) { return runtime.getMemoryManager().allocate(runtime.findType(type).size()); }
/** * Allocates a new block of native memory and wraps it in a {@link Pointer} * accessor. * * @param runtime The current runtime. * @param type The native type to allocate memory for. * * @return a {@code Pointer} instance that can access the memory. */ public static Pointer allocateDirect(Runtime runtime, NativeType type) { return runtime.getMemoryManager().allocateDirect(runtime.findType(type).size()); }
/** * Allocates a new block of java memory and wraps it in a {@link Pointer} * accessor. * * @param type The type alias to allocate memory for. * * @return a {@code Pointer} instance that can access the memory. */ public static Pointer allocate(Runtime runtime, TypeAlias type) { return runtime.getMemoryManager().allocate(runtime.findType(type).size()); }
/** * Allocates a new block of native memory and wraps it in a {@link Pointer} * accessor. * * @param type The type alias to allocate memory for. * * @return a {@code Pointer} instance that can access the memory. */ public static Pointer allocateDirect(Runtime runtime, TypeAlias type) { return runtime.getMemoryManager().allocateDirect(runtime.findType(type).size()); }
/** * Allocates a new block of java memory and wraps it in a {@link Pointer} * accessor. * * @param runtime The current runtime. * @param type The native type to allocate memory for. * * @return a {@code Pointer} instance that can access the memory. */ public static Pointer allocate(Runtime runtime, NativeType type) { return runtime.getMemoryManager().allocate(runtime.findType(type).size()); }
/** * Allocates a new block of java memory and wraps it in a {@link Pointer} * accessor. * * @param runtime The current runtime. * @param type The type alias to allocate memory for. * * @return a {@code Pointer} instance that can access the memory. */ public static Pointer allocate(Runtime runtime, TypeAlias type) { return runtime.getMemoryManager().allocate(runtime.findType(type).size()); }
/** * Allocates a new block of native memory and wraps it in a {@link Pointer} * accessor. * * @param type The native type to allocate memory for. * * @return a {@code Pointer} instance that can access the memory. */ public static Pointer allocateDirect(Runtime runtime, NativeType type) { return runtime.getMemoryManager().allocateDirect(runtime.findType(type).size()); }
/** * Allocates a new block of transient native memory and wraps it in a {@link Pointer} * accessor. The memory returned by this method should not be passed to native methods * that store the address for later use, as it may change each time it is passed to native code. * * @param type The native type to allocate memory for. * * @return a {@code Pointer} instance that can access the memory. */ public static Pointer allocateTemporary(Runtime runtime, NativeType type) { return runtime.getMemoryManager().allocateTemporary(runtime.findType(type).size(), true); }
/** * Allocates a new block of transient native memory and wraps it in a {@link Pointer} * accessor. The memory returned by this method should not be passed to native methods * that store the address for later use, as it may change each time it is passed to native code. * * @param type The type alias to allocate memory for. * * @return a {@code Pointer} instance that can access the memory. */ public static Pointer allocateTemporary(Runtime runtime, TypeAlias type) { return runtime.getMemoryManager().allocateTemporary(runtime.findType(type).size(), true); }
/** * Allocates a new block of native memory and wraps it in a {@link Pointer} * accessor. * * @param runtime The current runtime. * @param type The native type to allocate memory for. * * @return a {@code Pointer} instance that can access the memory. */ public static Pointer allocateDirect(Runtime runtime, NativeType type) { return runtime.getMemoryManager().allocateDirect(runtime.findType(type).size()); }
/** * Allocates a new block of java memory and wraps it in a {@link Pointer} * accessor. * * @param runtime The current runtime. * @param type The type alias to allocate memory for. * * @return a {@code Pointer} instance that can access the memory. */ public static Pointer allocate(Runtime runtime, TypeAlias type) { return runtime.getMemoryManager().allocate(runtime.findType(type).size()); }
/** * Gets the value for this field. * * @return a int. */ public final long get() { long value = getMemory().getNativeLong(offset()); final long mask = getRuntime().findType(NativeType.SLONG).size() == 32 ? 0xffffffffL : 0xffffffffffffffffL; return value < 0 ? (long) ((value & mask) + mask + 1) : value; }