public final synchronized NativeCallbackFactory getCallbackFactory(Ruby runtime, CallbackInfo cbInfo) { NativeCallbackFactory factory = factories.get(cbInfo); if (factory == null) { factories.put(cbInfo, factory = new NativeCallbackFactory(runtime, cbInfo)); } return factory; }
public final org.jruby.ext.ffi.Pointer getCallback(Ruby runtime, CallbackInfo cbInfo, Object proc) { return proc instanceof RubyObject ? getCallbackFactory(runtime, cbInfo).getCallback((RubyObject) proc) : getCallbackFactory(runtime, cbInfo).newCallback(proc); }
private final NativeFunctionInfo newFunctionInfo(Ruby runtime, CallbackInfo cbInfo) { org.jruby.ext.ffi.Type[] paramTypes = cbInfo.getParameterTypes(); for (int i = 0; i < paramTypes.length; ++i) { if (!isParameterTypeValid(paramTypes[i]) || FFIUtil.getFFIType(paramTypes[i]) == null) { throw runtime.newTypeError("invalid callback parameter type: " + paramTypes[i]); } } if (!isReturnTypeValid(cbInfo.getReturnType()) || FFIUtil.getFFIType(cbInfo.getReturnType()) == null) { throw runtime.newTypeError("invalid callback return type: " + cbInfo.getReturnType()); } return new NativeFunctionInfo(runtime, cbInfo.getReturnType(), cbInfo.getParameterTypes(), cbInfo.isStdcall() ? CallingConvention.STDCALL : CallingConvention.DEFAULT); }
private synchronized Pointer getCallbackPointer(IRubyObject callable, CachingCallSite callSite) { NativeCallbackPointer cbptr = (NativeCallbackPointer) closures.get(callable); if (cbptr != null) { return cbptr; } closures.put(callable, cbptr = newCallback(callable, callSite)); if (callable.getMetaClass().getFFIHandleAccessorForRead().get(callable) == null) { callable.getMetaClass().getFFIHandleAccessorForWrite().set(callable, cbptr); } return cbptr; }
public final Pointer getCallback(RubyObject callable) { return getCallback(callable, callSite); }
public NativeCallbackFactory(Ruby runtime, CallbackInfo cbInfo) { this.runtime = runtime; this.closureInfo = newFunctionInfo(runtime, cbInfo); this.closurePool = com.kenai.jffi.ClosureManager.getInstance().getClosurePool(closureInfo.callContext); this.callbackInfo = cbInfo; this.callbackClass = runtime.getModule("FFI").getClass("Callback"); }
public final Pointer getCallback(IRubyObject callable, CachingCallSite callSite) { if (callable instanceof Pointer) { return (Pointer) callable; } Object ffiHandle = callable.getMetaClass().getRealClass().getFFIHandleAccessorField().getVariableAccessorForRead().get(callable); NativeCallbackPointer cbptr; if (ffiHandle instanceof NativeCallbackPointer && ((cbptr = (NativeCallbackPointer) ffiHandle).cbInfo == callbackInfo)) { return cbptr; } return getCallbackPointer(callable, callSite); }
return isParameterTypeValid(((MappedType) type).getRealType());
private final NativeFunctionInfo newFunctionInfo(Ruby runtime, CallbackInfo cbInfo) { org.jruby.ext.ffi.Type[] paramTypes = cbInfo.getParameterTypes(); for (int i = 0; i < paramTypes.length; ++i) { if (!isParameterTypeValid(paramTypes[i]) || FFIUtil.getFFIType(paramTypes[i]) == null) { throw runtime.newTypeError("invalid callback parameter type: " + paramTypes[i]); } } if (!isReturnTypeValid(cbInfo.getReturnType()) || FFIUtil.getFFIType(cbInfo.getReturnType()) == null) { runtime.newTypeError("invalid callback return type: " + cbInfo.getReturnType()); } return new NativeFunctionInfo(runtime, cbInfo.getReturnType(), cbInfo.getParameterTypes(), cbInfo.isStdcall() ? CallingConvention.STDCALL : CallingConvention.DEFAULT); }
private synchronized Pointer getCallbackPointer(IRubyObject callable, CachingCallSite callSite) { NativeCallbackPointer cbptr = (NativeCallbackPointer) closures.get(callable); if (cbptr != null) { return cbptr; } closures.put(callable, cbptr = newCallback(callable, callSite)); if (callable.getMetaClass().getFFIHandleAccessorForRead().get(callable) == null) { callable.getMetaClass().getFFIHandleAccessorForWrite().set(callable, cbptr); } return cbptr; }
public final Pointer getCallback(RubyObject callable) { return getCallback(callable, callSite); }
public NativeCallbackFactory(Ruby runtime, CallbackInfo cbInfo) { this.runtime = runtime; this.closureInfo = newFunctionInfo(runtime, cbInfo); this.closurePool = com.kenai.jffi.ClosureManager.getInstance().getClosurePool(closureInfo.callContext); this.callbackInfo = cbInfo; this.callbackClass = runtime.getModule("FFI").getClass("Callback"); }
public final Pointer getCallback(IRubyObject callable, CachingCallSite callSite) { if (callable instanceof Pointer) { return (Pointer) callable; } Object ffiHandle = callable.getMetaClass().getRealClass().getFFIHandleAccessorField().getVariableAccessorForRead().get(callable); NativeCallbackPointer cbptr; if (ffiHandle instanceof NativeCallbackPointer && ((cbptr = (NativeCallbackPointer) ffiHandle).cbInfo == callbackInfo)) { return cbptr; } return getCallbackPointer(callable, callSite); }
return isParameterTypeValid(((MappedType) type).getRealType());
public final org.jruby.ext.ffi.Pointer getCallback(Ruby runtime, CallbackInfo cbInfo, Object proc) { return proc instanceof RubyObject ? getCallbackFactory(runtime, cbInfo).getCallback((RubyObject) proc) : getCallbackFactory(runtime, cbInfo).newCallback(proc); }
private final NativeFunctionInfo newFunctionInfo(Ruby runtime, CallbackInfo cbInfo) { org.jruby.ext.ffi.Type[] paramTypes = cbInfo.getParameterTypes(); for (int i = 0; i < paramTypes.length; ++i) { if (!isParameterTypeValid(paramTypes[i]) || FFIUtil.getFFIType(paramTypes[i]) == null) { throw runtime.newTypeError("invalid callback parameter type: " + paramTypes[i]); } } if (!isReturnTypeValid(cbInfo.getReturnType()) || FFIUtil.getFFIType(cbInfo.getReturnType()) == null) { throw runtime.newTypeError("invalid callback return type: " + cbInfo.getReturnType()); } return new NativeFunctionInfo(runtime, cbInfo.getReturnType(), cbInfo.getParameterTypes(), cbInfo.isStdcall() ? CallingConvention.STDCALL : CallingConvention.DEFAULT); }
private synchronized Pointer getCallbackPointer(IRubyObject callable, CachingCallSite callSite) { NativeCallbackPointer cbptr = (NativeCallbackPointer) closures.get(callable); if (cbptr != null) { return cbptr; } closures.put(callable, cbptr = newCallback(callable, callSite)); if (callable.getMetaClass().getFFIHandleAccessorForRead().get(callable) == null) { callable.getMetaClass().getFFIHandleAccessorForWrite().set(callable, cbptr); } return cbptr; }
public final Pointer getCallback(RubyObject callable) { return getCallback(callable, callSite); }
public NativeCallbackFactory(Ruby runtime, CallbackInfo cbInfo) { this.runtime = runtime; this.closureInfo = newFunctionInfo(runtime, cbInfo); this.closurePool = com.kenai.jffi.ClosureManager.getInstance().getClosurePool(closureInfo.callContext); this.callbackInfo = cbInfo; this.callbackClass = runtime.getModule("FFI").getClass("Callback"); }
public final Pointer getCallback(IRubyObject callable, CachingCallSite callSite) { if (callable instanceof Pointer) { return (Pointer) callable; } Object ffiHandle = callable.getMetaClass().getRealClass().getFFIHandleAccessorField().getVariableAccessorForRead().get(callable); NativeCallbackPointer cbptr; if (ffiHandle instanceof NativeCallbackPointer && ((cbptr = (NativeCallbackPointer) ffiHandle).cbInfo == callbackInfo)) { return cbptr; } return getCallbackPointer(callable, callSite); }