/** * Call the native function being represented by this object * * @param callFlags calling convention to be used * @param args * Arguments to pass to the native function * @param wide whether the native string uses <code>wchar_t</code>; * if false, <code>char</code> is assumed * @return The value returned by the target native function, as a String */ private String invokeString(int callFlags, Object[] args, boolean wide) { Pointer ptr = invokePointer(callFlags, args); String s = null; if (ptr != null) { if (wide) { s = ptr.getWideString(0); } else { s = ptr.getString(0, encoding); } } return s; }
return invokePointer(callFlags, args); } else if (Structure.class.isAssignableFrom(returnType)) { if (Structure.ByValue.class.isAssignableFrom(returnType)) { result = s; } else { result = invokePointer(callFlags, args); if (result != null) { Structure s = Structure.newInstance((Class<? extends Structure>)returnType, (Pointer)result); result = invokePointer(callFlags, args); if (result != null) { result = CallbackReference.getCallback(returnType, (Pointer)result); Pointer p = invokePointer(callFlags, args); if (p != null) { result = p.getStringArray(0, encoding); Pointer p = invokePointer(callFlags, args); if (p != null) { String[] arr = p.getWideStringArray(0); Pointer p = invokePointer(callFlags, args); if (p != null) { result = p.getPointerArray(0);
public final IRubyObject invoke(Ruby runtime, Function function, Object[] args) { return new JNAMemoryPointer(runtime, function.invokePointer(args)); } public static final FunctionInvoker INSTANCE = new PointerInvoker();
/** * Call the native function being represented by this object * * @param callFlags calling convention to be used * @param args * Arguments to pass to the native function * @param wide whether the native string uses <code>wchar_t</code>; * if false, <code>char</code> is assumed * @return The value returned by the target native function, as a String */ private String invokeString(int callFlags, Object[] args, boolean wide) { Pointer ptr = invokePointer(callFlags, args); String s = null; if (ptr != null) { if (wide) { s = ptr.getWideString(0); } else { s = ptr.getString(0, encoding); } } return s; }
return invokePointer(callFlags, args); } else if (Structure.class.isAssignableFrom(returnType)) { if (Structure.ByValue.class.isAssignableFrom(returnType)) { result = s; } else { result = invokePointer(callFlags, args); if (result != null) { Structure s = Structure.newInstance(returnType, (Pointer)result); result = invokePointer(callFlags, args); if (result != null) { result = CallbackReference.getCallback(returnType, (Pointer)result); Pointer p = invokePointer(callFlags, args); if (p != null) { result = p.getStringArray(0, encoding); Pointer p = invokePointer(callFlags, args); if (p != null) { String[] arr = p.getWideStringArray(0); Pointer p = invokePointer(callFlags, args); if (p != null) { result = p.getPointerArray(0);
result = invokePointer(callingConvention, args); if (result != null) { Structure s = Structure.newInstance(returnType); result = invokePointer(callingConvention, args); if (result != null) { result = CallbackReference.getCallback(returnType, (Pointer)result);
public final IRubyObject invoke(Ruby runtime, Function function, Object[] args) { Pointer address = function.invokePointer(args); if (address == null) { return runtime.getNil(); } int len = (int) address.indexOf(0, (byte) 0); if (len == 0) { return RubyString.newEmptyString(runtime); } ByteList bl = new ByteList(len); bl.length(len); address.read(0, bl.unsafeBytes(), bl.begin(), len); return RubyString.newString(runtime, bl); } public static final FunctionInvoker INSTANCE = new StringInvoker();