/** * 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); }
/** 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); }
/** Convenience method for * {@link #invoke(Class,Object[]) invokeObject(Object.class, args)}. */ public Object invokeObject(Object[] args) { return invoke(Object.class, args); }
/** Convenience method for * {@link #invoke(Class,Object[]) invoke(Pointer.class, args)}. */ public Pointer invokePointer(Object[] args) { return (Pointer)invoke(Pointer.class, args); }
/** Convenience method for * {@link #invoke(Class,Object[]) invoke(Void.class, args)}. */ public void invokeVoid(Object[] args) { invoke(Void.class, args); }
Object invoke(Object[] args, Class<?> returnType, boolean allowObjects) { return invoke(args, returnType, allowObjects, 0); }
/** 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
/** 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
/** 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; }
/** 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
/** 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
/** 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); }
/** 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); }
return f.handler.invoke(proxy, method, inArgs); return f.function.invoke(method, f.parameterTypes, method.getReturnType(), inArgs, f.options);
Object result = invoke(args, nativeReturnType, allowObjects, fixedArgs);
/** Convenience method for * {@link #invoke(Class,Object[]) invokeObject(Object.class, args)}. */ public Object invokeObject(Object[] args) { return invoke(Object.class, args); }
/** * 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); }
/** 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
public final IRubyObject invoke(Ruby runtime, Function function, Object[] args) { function.invoke(args); return runtime.getNil(); } public static final FunctionInvoker INSTANCE = new VoidInvoker();
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); }