本文整理了Java中com.sun.jna.Function.<init>()
方法的一些代码示例,展示了Function.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Function.<init>()
方法的具体详情如下:
包路径:com.sun.jna.Function
类名称:Function
方法名:<init>
[英]Create a new Function
that is linked with a native function that follows the given calling convention.
The allocated instance represents a pointer to the named native function from the supplied library, called with the given calling convention.
[中]创建与遵循给定调用约定的本机函数链接的新Function
。
分配的实例表示指向所提供库中的命名本机函数的指针,该函数使用给定的调用约定进行调用。
代码示例来源:origin: net.java.dev.jna/jna
/**
* Obtain a <code>Function</code> representing a native
* function pointer. In general, this function should be used by dynamic
* languages; Java code should allow JNA to bind to a specific Callback
* interface instead by defining a return type or Structure field type.
*
* <p>The allocated instance represents a pointer to the native
* function pointer.
*
* @param p
* Native function pointer
* @param callFlags
* Function <a href="#callflags">call flags</a>
* @param encoding
* Encoding to use for conversion between Java and native
* strings.
*/
public static Function getFunction(Pointer p, int callFlags, String encoding) {
return new Function(p, callFlags, encoding);
}
代码示例来源:origin: net.java.dev.jna/jna
public NativeFunctionHandler(Pointer address, int callingConvention, Map<String, ?> options) {
this.options = options;
this.function = new Function(address, callingConvention, (String) options.get(Library.OPTION_STRING_ENCODING));
}
代码示例来源:origin: net.java.dev.jna/jna
/**
* Create a new {@link Function} that is linked with a native
* function that follows a given calling flags.
*
* @param functionName
* Name of the native function to be linked with
* @param callFlags
* Flags affecting the function invocation
* @param encoding
* Encoding to use to convert between Java and native
* strings.
* @throws UnsatisfiedLinkError if the function is not found
*/
public Function getFunction(String functionName, int callFlags, String encoding) {
if (functionName == null) {
throw new NullPointerException("Function name may not be null");
}
synchronized (functions) {
String key = functionKey(functionName, callFlags, encoding);
Function function = functions.get(key);
if (function == null) {
function = new Function(this, functionName, callFlags, encoding);
functions.put(key, function);
}
return function;
}
}
代码示例来源:origin: net.java.dev.jna/jna
private NativeLibrary(String libraryName, String libraryPath, long handle, Map<String, ?> options) {
this.libraryName = getLibraryName(libraryName);
this.libraryPath = libraryPath;
this.handle = handle;
Object option = options.get(Library.OPTION_CALLING_CONVENTION);
int callingConvention = option instanceof Number ? ((Number)option).intValue() : Function.C_CONVENTION;
this.callFlags = callingConvention;
this.options = options;
this.encoding = (String)options.get(Library.OPTION_STRING_ENCODING);
if (this.encoding == null) {
this.encoding = Native.getDefaultStringEncoding();
}
// Special workaround for w32 kernel32.GetLastError
// Short-circuit the function to use built-in GetLastError access
if (Platform.isWindows() && "kernel32".equals(this.libraryName.toLowerCase())) {
synchronized(functions) {
Function f = new Function(this, "GetLastError", Function.ALT_CONVENTION, encoding) {
@Override
Object invoke(Object[] args, Class<?> returnType, boolean b, int fixedArgs) {
return Integer.valueOf(Native.getLastError());
}
@Override
Object invoke(Method invokingMethod, Class<?>[] paramTypes, Class<?> returnType, Object[] inArgs, Map<String, ?> options) {
return Integer.valueOf(Native.getLastError());
}
};
functions.put(functionKey("GetLastError", callFlags, encoding), f);
}
}
}
代码示例来源:origin: org.elasticsearch/jna
/**
* Obtain a <code>Function</code> representing a native
* function pointer. In general, this function should be used by dynamic
* languages; Java code should allow JNA to bind to a specific Callback
* interface instead by defining a return type or Structure field type.
*
* <p>The allocated instance represents a pointer to the native
* function pointer.
*
* @param p
* Native function pointer
* @param callFlags
* Function <a href="#callflags">call flags</a>
* @param encoding
* Encoding to use for conversion between Java and native
* strings.
*/
public static Function getFunction(Pointer p, int callFlags, String encoding) {
return new Function(p, callFlags, encoding);
}
代码示例来源:origin: org.elasticsearch/jna
public NativeFunctionHandler(Pointer address, int callingConvention, Map<String, ?> options) {
this.options = options;
this.function = new Function(address, callingConvention, (String) options.get(Library.OPTION_STRING_ENCODING));
}
代码示例来源:origin: com.sun.jna/jna
private NativeLibrary(String libraryName, String libraryPath, long handle) {
this.libraryName = getLibraryName(libraryName);
this.libraryPath = libraryPath;
this.handle = handle;
// Special workaround for w32 kernel32.GetLastError
// Short-circuit the function to use built-in GetLastError access
if (Platform.isWindows() && "kernel32".equals(this.libraryName.toLowerCase())) {
synchronized(functions) {
Function f = new Function(this, "GetLastError", Function.ALT_CONVENTION) {
Object invoke(Object[] args, Class returnType) {
return new Integer(Native.getLastError());
}
};
functions.put("GetLastError", f);
}
}
}
代码示例来源:origin: org.elasticsearch/jna
/**
* Create a new {@link Function} that is linked with a native
* function that follows a given calling flags.
*
* @param functionName
* Name of the native function to be linked with
* @param callFlags
* Flags affecting the function invocation
* @param encoding
* Encoding to use to convert between Java and native
* strings.
* @throws UnsatisfiedLinkError if the function is not found
*/
public Function getFunction(String functionName, int callFlags, String encoding) {
if (functionName == null) {
throw new NullPointerException("Function name may not be null");
}
synchronized (functions) {
String key = functionKey(functionName, callFlags, encoding);
Function function = functions.get(key);
if (function == null) {
function = new Function(this, functionName, callFlags, encoding);
functions.put(key, function);
}
return function;
}
}
代码示例来源:origin: org.elasticsearch/jna
private NativeLibrary(String libraryName, String libraryPath, long handle, Map<String, ?> options) {
this.libraryName = getLibraryName(libraryName);
this.libraryPath = libraryPath;
this.handle = handle;
Object option = options.get(Library.OPTION_CALLING_CONVENTION);
int callingConvention = option instanceof Number ? ((Number)option).intValue() : Function.C_CONVENTION;
this.callFlags = callingConvention;
this.options = options;
this.encoding = (String)options.get(Library.OPTION_STRING_ENCODING);
if (this.encoding == null) {
this.encoding = Native.getDefaultStringEncoding();
}
// Special workaround for w32 kernel32.GetLastError
// Short-circuit the function to use built-in GetLastError access
if (Platform.isWindows() && "kernel32".equals(this.libraryName.toLowerCase())) {
synchronized(functions) {
Function f = new Function(this, "GetLastError", Function.ALT_CONVENTION, encoding) {
@Override
Object invoke(Object[] args, Class<?> returnType, boolean b, int fixedArgs) {
return Integer.valueOf(Native.getLastError());
}
@Override
Object invoke(Method invokingMethod, Class<?>[] paramTypes, Class<?> returnType, Object[] inArgs, Map<String, ?> options) {
return Integer.valueOf(Native.getLastError());
}
};
functions.put(functionKey("GetLastError", callFlags, encoding), f);
}
}
}
代码示例来源:origin: com.sun.jna/jna
Function function = (Function) functions.get(functionName);
if (function == null) {
function = new Function(this, functionName, callingConvention);
functions.put(functionName, function);
内容来源于网络,如有侵权,请联系作者删除!