本文整理了Java中com.sun.jna.Native.getNativeSize()
方法的一些代码示例,展示了Native.getNativeSize()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Native.getNativeSize()
方法的具体详情如下:
包路径:com.sun.jna.Native
类名称:Native
方法名:getNativeSize
[英]Returns the native size for a given Java class. Structures are assumed to be struct
pointers unless they implement Structure.ByValue.
[中]返回给定Java类的本机大小。结构被假定为struct
指针,除非它们实现了结构。ByValue。
代码示例来源:origin: net.java.dev.jna/jna
/** Return the native size of the given Java type, from the perspective of
* this Structure.
* @param nativeType field type to examine
* @param value instance of the field type
* @return native size (in bytes) of the requested field type
*/
protected int getNativeSize(Class<?> nativeType, Object value) {
return Native.getNativeSize(nativeType, value);
}
代码示例来源:origin: net.java.dev.jna/jna
/**
* @param cls The Java class
* @return {@code true} whether the given class is supported as a native argument type.
*/
public static boolean isSupportedNativeType(Class<?> cls) {
if (Structure.class.isAssignableFrom(cls)) {
return true;
}
try {
return getNativeSize(cls) != 0;
}
catch(IllegalArgumentException e) {
return false;
}
}
代码示例来源:origin: net.java.dev.jna/jna
public NativeMappedArray(NativeMapped[] arg) {
super(Native.getNativeSize(arg.getClass(), arg));
this.original = arg;
setValue(0, original, original.getClass());
}
@Override
代码示例来源:origin: net.java.dev.jna/jna
/**
* @param type The Java class for which the native size is to be determined
* @param value an instance of said class (if available)
* @return the native size of the given class, in bytes.
* For use with arrays.
*/
public static int getNativeSize(Class<?> type, Object value) {
if (type.isArray()) {
int len = Array.getLength(value);
if (len > 0) {
Object o = Array.get(value, 0);
return len * getNativeSize(type.getComponentType(), o);
}
// Don't process zero-length arrays
throw new IllegalArgumentException("Arrays of length zero not allowed: " + type);
}
if (Structure.class.isAssignableFrom(type)
&& !Structure.ByReference.class.isAssignableFrom(type)) {
return Structure.size((Class<Structure>) type, (Structure)value);
}
try {
return getNativeSize(type);
}
catch(IllegalArgumentException e) {
throw new IllegalArgumentException("The type \"" + type.getName()
+ "\" is not supported: "
+ e.getMessage());
}
}
代码示例来源:origin: net.java.dev.jna/jna
/** 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);
}
}
代码示例来源:origin: net.java.dev.jna/jna
value = tc.toNative(value, new ToNativeContext());
int size = Native.getNativeSize(type, value);
if (type.isPrimitive() || Long.class == type || Integer.class == type
|| Short.class == type || Character.class == type
代码示例来源:origin: net.java.dev.jna/jna-platform
public static int sizeOf()
{
return Native.getNativeSize(FILE_COMPRESSION_INFO.class, null);
}
代码示例来源:origin: net.java.dev.jna/jna-platform
/**
* Helper function to calculate the size of an ACE for a given PSID size
* @param sidLength length of the sid
* @return size of the ACE
*/
public static int getAceSize(int sidLength) {
return Native.getNativeSize(ACCESS_ALLOWED_ACE.class, null)
+ sidLength
- DWORD.SIZE;
}
代码示例来源:origin: org.elasticsearch/jna
/** Return the native size of the given Java type, from the perspective of
* this Structure.
* @param nativeType field type to examine
* @param value instance of the field type
* @return native size (in bytes) of the requested field type
*/
protected int getNativeSize(Class<?> nativeType, Object value) {
return Native.getNativeSize(nativeType, value);
}
代码示例来源:origin: EtiennePerot/fuse-jna
public static final int size(@SuppressWarnings("rawtypes") final Class cls)
{
return Native.getNativeSize(cls);
}
}
代码示例来源:origin: net.java.dev.jna/jna-platform
public static int sizeOf()
{
return Native.getNativeSize(FILE_ATTRIBUTE_TAG_INFO.class, null);
}
代码示例来源:origin: net.java.dev.jna/jna-platform
public static int sizeOf()
{
return Native.getNativeSize(FILE_DISPOSITION_INFO.class, null);
}
代码示例来源:origin: net.java.dev.jna/jna-platform
public static int sizeOf()
{
return Native.getNativeSize(FILE_BASIC_INFO.class, null);
}
代码示例来源:origin: net.java.dev.jna/jna-platform
public static int sizeOf()
{
return Native.getNativeSize(FILE_STANDARD_INFO.class, null);
}
代码示例来源:origin: net.java.dev.jna/jna-platform
public static int sizeOf()
{
return Native.getNativeSize(FILE_ID_INFO.class, null);
}
代码示例来源:origin: net.java.dev.jna/jna-platform
public static int sizeOf() {
return Native.getNativeSize(WIN32_FIND_DATA.class, null);
}
代码示例来源:origin: net.java.dev.jna/jna
NativeMapped[] array = (NativeMapped[])result;
NativeMappedConverter tc = NativeMappedConverter.getInstance(cls);
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]);
代码示例来源:origin: net.java.dev.jna/jna
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++) {
Object element = tc.toNative(buf[i], new ToNativeContext());
代码示例来源:origin: org.elasticsearch/jna
public NativeMappedArray(NativeMapped[] arg) {
super(Native.getNativeSize(arg.getClass(), arg));
this.original = arg;
setValue(0, original, original.getClass());
}
@Override
代码示例来源:origin: com.dukescript.presenters/webkit
public Pointer call(
Pointer jsContextRef, Pointer jsFunction, Pointer thisObject,
int argumentCount, PointerByReference ref, Pointer exception
) throws Exception {
JSC jsc = shell.jsc();
int size = Native.getNativeSize(Pointer.class);
Object[] args = new Object[argumentCount];
for (int i = 0, offset = 0; i < argumentCount; i++, offset += size) {
args[i] = convertToJava(jsc, method.getParameterTypes()[i], ref.getPointer().getPointer(offset));
}
return convertFromJava(method.invoke(vm, args))[0];
}
}
内容来源于网络,如有侵权,请联系作者删除!