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

x33g5p2x  于2022-01-19 转载在 其他  
字(5.6k)|赞(0)|评价(0)|浏览(296)

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

Function.invoke介绍

[英]Invoke the native function with the given arguments, returning the native result as an Object.
[中]使用给定参数调用本机函数,并将本机结果作为对象返回。

代码示例

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

/**
 * Call the native function being represented by this object
 *
 * @param    args
 *            Arguments to pass to the native function
 */
public void invoke(Object[] args) {
  invoke(Void.class, args);
}

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

/** Invoke the native function with the given arguments, returning the
 * native result as an Object.
 */
public Object invoke(Class<?> returnType, Object[] inArgs) {
  return invoke(returnType, inArgs, this.options);
}

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

/** Convenience method for
 * {@link #invoke(Class,Object[]) invokeObject(Object.class, args)}.
 */
public Object invokeObject(Object[] args) {
  return invoke(Object.class, args);
}

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

/** Convenience method for
 * {@link #invoke(Class,Object[]) invoke(Pointer.class, args)}.
 */
public Pointer invokePointer(Object[] args) {
  return (Pointer)invoke(Pointer.class, args);
}

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

/** Convenience method for
 * {@link #invoke(Class,Object[]) invoke(Void.class, args)}.
 */
public void invokeVoid(Object[] args) {
  invoke(Void.class, args);
}

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

Object invoke(Object[] args, Class<?> returnType, boolean allowObjects) {
return invoke(args, returnType, allowObjects, 0);
}

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

/** Convenience method for
 * {@link #invoke(Class,Object[]) invoke(Float.class, args)}.
 */
public float invokeFloat(Object[] args) {
  return ((Float)invoke(Float.class, args)).floatValue();
}
/** Convenience method for

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

/** Convenience method for
 * {@link #invoke(Class,Object[]) invoke(Double.class, args)}.
 */
public double invokeDouble(Object[] args) {
  return ((Double)invoke(Double.class, args)).doubleValue();
}
/** Convenience method for

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

/** Convenience method for
 * {@link #invoke(Class,Object[]) invoke(String.class, args)}
 * or {@link #invoke(Class,Object[]) invoke(WString.class, args)}
 * @param args Arguments passed to native function
 * @param wide Whether the return value is of type <code>wchar_t*</code>;
 * if false, the return value is of type <code>char*</code>.
 */
public String invokeString(Object[] args, boolean wide) {
  Object o = invoke(wide ? WString.class : String.class, args);
  return o != null ? o.toString() : null;
}

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

/** Convenience method for
 * {@link #invoke(Class,Object[]) invoke(Integer.class, args)}.
 */
public int invokeInt(Object[] args) {
  return ((Integer)invoke(Integer.class, args)).intValue();
}
/** Convenience method for

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

/** Convenience method for
 * {@link #invoke(Class,Object[]) invoke(Long.class, args)}.
 */
public long invokeLong(Object[] args) {
  return ((Long)invoke(Long.class, args)).longValue();
}
/** Convenience method for

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

/** Invoke the native function with the given arguments, returning the
 * native result as an Object.
 */
public Object invoke(Class<?> returnType, Object[] inArgs, Map<String, ?> options) {
  Method invokingMethod = (Method)options.get(OPTION_INVOKING_METHOD);
  Class<?>[] paramTypes = invokingMethod != null ? invokingMethod.getParameterTypes() : null;
  return invoke(invokingMethod, paramTypes, returnType, inArgs, options);
}

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

/** Chain invocation to the native function. */
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
  if (Library.Handler.OBJECT_TOSTRING.equals(method)) {
    String str = "Proxy interface to " + function;
    Method m = (Method)options.get(Function.OPTION_INVOKING_METHOD);
    Class<?> cls = findCallbackClass(m.getDeclaringClass());
    str += " (" + cls.getName() + ")";
    return str;
  } else if (Library.Handler.OBJECT_HASHCODE.equals(method)) {
    return Integer.valueOf(hashCode());
  } else if (Library.Handler.OBJECT_EQUALS.equals(method)) {
    Object o = args[0];
    if (o != null && Proxy.isProxyClass(o.getClass())) {
      return Function.valueOf(Proxy.getInvocationHandler(o) == this);
    }
    return Boolean.FALSE;
  }
  if (Function.isVarArgs(method)) {
    args = Function.concatenateVarArgs(args);
  }
  return function.invoke(method.getReturnType(), args, options);
}

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

return f.handler.invoke(proxy, method, inArgs);
return f.function.invoke(method, f.parameterTypes, method.getReturnType(), inArgs, f.options);

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

Object result = invoke(args, nativeReturnType, allowObjects, fixedArgs);

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

/** Convenience method for
 * {@link #invoke(Class,Object[]) invokeObject(Object.class, args)}.
 */
public Object invokeObject(Object[] args) {
  return invoke(Object.class, args);
}

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

/**
 * Call the native function being represented by this object
 *
 * @param    args
 *            Arguments to pass to the native function
 */
public void invoke(Object[] args) {
  invoke(Void.class, args);
}

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

/** Convenience method for
 * {@link #invoke(Class,Object[]) invoke(Long.class, args)}.
 */
public long invokeLong(Object[] args) {
  return ((Long)invoke(Long.class, args)).longValue();
}
/** Convenience method for

代码示例来源:origin: org.netbeans.api/org-jruby

public final IRubyObject invoke(Ruby runtime, Function function, Object[] args) {
  function.invoke(args);
  return runtime.getNil();
}
public static final FunctionInvoker INSTANCE = new VoidInvoker();

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

protected Object _invokeNativeObject(int vtableId, Object[] args, Class<?> returnType) {
  Pointer vptr = this.getPointer().getPointer(0);
  // we take the vtable id and multiply with the pointer size (4 bytes on
  // 32bit OS)
  Function func = Function.getFunction(vptr.getPointer(vtableId
      * Native.POINTER_SIZE));
  return func.invoke(returnType, args);
}

相关文章