com.sun.jna.Native.getLibraryOptions()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(5.5k)|赞(0)|评价(0)|浏览(145)

本文整理了Java中com.sun.jna.Native.getLibraryOptions()方法的一些代码示例,展示了Native.getLibraryOptions()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Native.getLibraryOptions()方法的具体详情如下:
包路径:com.sun.jna.Native
类名称:Native
方法名:getLibraryOptions

Native.getLibraryOptions介绍

[英]Return the preferred native library configuration options for the given class.
[中]返回给定类的首选本机库配置选项。

代码示例

代码示例来源:origin: net.java.dev.jna/jna

/** Return the preferred {@link TypeMapper} for the given native interface.
 * See {@link com.sun.jna.Library#OPTION_TYPE_MAPPER}.
 */
public static TypeMapper getTypeMapper(Class<?> cls) {
  Map<String, ?> options = getLibraryOptions(cls);
  return (TypeMapper) options.get(Library.OPTION_TYPE_MAPPER);
}

代码示例来源:origin: net.java.dev.jna/jna

/**
 * @param cls The native interface type
 * @return The preferred structure alignment for the given native interface.
 * @see com.sun.jna.Library#OPTION_STRUCTURE_ALIGNMENT
 */
public static int getStructureAlignment(Class<?> cls) {
  Integer alignment = (Integer)getLibraryOptions(cls).get(Library.OPTION_STRUCTURE_ALIGNMENT);
  return alignment == null ? Structure.ALIGN_DEFAULT : alignment;
}

代码示例来源:origin: net.java.dev.jna/jna

/**
 * @param cls The native interface type
 * @return The preferred string encoding for the given native interface.
 * If there is no setting, defaults to the {@link #getDefaultStringEncoding()}.
 * @see com.sun.jna.Library#OPTION_STRING_ENCODING
 */
public static String getStringEncoding(Class<?> cls) {
  Map<String, ?> options = getLibraryOptions(cls);
  String encoding = (String) options.get(Library.OPTION_STRING_ENCODING);
  return encoding != null ? encoding : getDefaultStringEncoding();
}

代码示例来源:origin: net.java.dev.jna/jna

Map<String, Object> foptions = new HashMap<String, Object>(Native.getLibraryOptions(type));
foptions.put(Function.OPTION_INVOKING_METHOD, getCallbackMethod(type));
NativeFunctionHandler h = new NativeFunctionHandler(p, ctype, foptions);

代码示例来源:origin: net.java.dev.jna/jna

/** Native code may call this method with direct=true. */
private static Pointer getFunctionPointer(Callback cb, boolean direct) {
  Pointer fp = null;
  if (cb == null) {
    return null;
  }
  if ((fp = getNativeFunctionPointer(cb)) != null) {
    return fp;
  }
  Map<String, ?> options = Native.getLibraryOptions(cb.getClass());
  int callingConvention = cb instanceof AltCallingConvention
    ? Function.ALT_CONVENTION
    : (options != null && options.containsKey(Library.OPTION_CALLING_CONVENTION)
      ? ((Integer)options.get(Library.OPTION_CALLING_CONVENTION)).intValue()
      : Function.C_CONVENTION);
  Map<Callback, CallbackReference> map = direct ? directCallbackMap : callbackMap;
  synchronized(pointerCallbackMap) {
    CallbackReference cbref = map.get(cb);
    if (cbref == null) {
      cbref = new CallbackReference(cb, callingConvention, direct);
      map.put(cb, cbref);
      pointerCallbackMap.put(cbref.getTrampoline(), new WeakReference<Callback>(cb));
      if (initializers.containsKey(cb)) {
        cbref.setCallbackOptions(Native.CB_HAS_INITIALIZER);
      }
    }
    return cbref.getTrampoline();
  }
}

代码示例来源:origin: org.elasticsearch/jna

/** Return the preferred {@link TypeMapper} for the given native interface.
 * See {@link com.sun.jna.Library#OPTION_TYPE_MAPPER}.
 */
public static TypeMapper getTypeMapper(Class<?> cls) {
  Map<String, ?> options = getLibraryOptions(cls);
  return (TypeMapper) options.get(Library.OPTION_TYPE_MAPPER);
}

代码示例来源:origin: org.elasticsearch/jna

/**
 * @param cls The native interface type
 * @return The preferred structure alignment for the given native interface.
 * @see com.sun.jna.Library#OPTION_STRUCTURE_ALIGNMENT
 */
public static int getStructureAlignment(Class<?> cls) {
  Integer alignment = (Integer)getLibraryOptions(cls).get(Library.OPTION_STRUCTURE_ALIGNMENT);
  return alignment == null ? Structure.ALIGN_DEFAULT : alignment.intValue();
}

代码示例来源:origin: org.elasticsearch/jna

/**
 * @param cls The native interface type
 * @return The preferred string encoding for the given native interface.
 * If there is no setting, defaults to the {@link #getDefaultStringEncoding()}.
 * @see com.sun.jna.Library#OPTION_STRING_ENCODING
 */
public static String getStringEncoding(Class<?> cls) {
  Map<String, ?> options = getLibraryOptions(cls);
  String encoding = (String) options.get(Library.OPTION_STRING_ENCODING);
  return encoding != null ? encoding : getDefaultStringEncoding();
}

代码示例来源:origin: com.sun.jna/jna

private interface NativeFunctionProxy { }

代码示例来源:origin: com.sun.jna/jna

Map options = getLibraryOptions(cls);
if (options != null
  && options.containsKey(Library.OPTION_STRUCTURE_ALIGNMENT)) {

代码示例来源:origin: org.elasticsearch/jna

Map<String, Object> foptions = new HashMap<String, Object>(Native.getLibraryOptions(type));
foptions.put(Function.OPTION_INVOKING_METHOD, getCallbackMethod(type));
NativeFunctionHandler h = new NativeFunctionHandler(p, ctype, foptions);

代码示例来源:origin: org.elasticsearch/jna

/** Native code may call this method with direct=true. */
private static Pointer getFunctionPointer(Callback cb, boolean direct) {
  Pointer fp = null;
  if (cb == null) {
    return null;
  }
  if ((fp = getNativeFunctionPointer(cb)) != null) {
    return fp;
  }
  Map<String, ?> options = Native.getLibraryOptions(cb.getClass());
  int callingConvention = cb instanceof AltCallingConvention
    ? Function.ALT_CONVENTION
    : (options != null && options.containsKey(Library.OPTION_CALLING_CONVENTION)
      ? ((Integer)options.get(Library.OPTION_CALLING_CONVENTION)).intValue()
      : Function.C_CONVENTION);
  Map<Callback, CallbackReference> map = direct ? directCallbackMap : callbackMap;
  synchronized(pointerCallbackMap) {
    CallbackReference cbref = map.get(cb);
    if (cbref == null) {
      cbref = new CallbackReference(cb, callingConvention, direct);
      map.put(cb, cbref);
      pointerCallbackMap.put(cbref.getTrampoline(), new WeakReference<Callback>(cb));
      if (initializers.containsKey(cb)) {
        cbref.setCallbackOptions(Native.CB_HAS_INITIALIZER);
      }
    }
    return cbref.getTrampoline();
  }
}

相关文章

Native类方法