HttpClient mockHttpClient = mock(HttpClient.class); when(mockHttpClient.executeMethod(any(GetMethod.class)).thenReturn(HttpStatus.SC_OK); MethodFactory factory = mock(MethodFactory.class); GetMethod get = mock(GetMethod.class); when(factory.createMethod()).thenReturn(get); when(get.getResponseBodyAsStream()).thenReturn(new FileInputStream(source));
public void marshal(Invocation invocation, InvocationBuffer buffer, IRubyObject parameter) { ThreadContext context = invocation.getThreadContext(); final IRubyObject nativeValue = converter.toNative(context, parameter); // keep a hard ref to the converted value if needed if (converter.isReferenceRequired()) { invocation.addReference(nativeValue); } nativeMarshaller.marshal(context, buffer, nativeValue); }
@Override public DynamicMethod createDynamicMethod(RubyModule module) { return MethodFactory.createDynamicMethod(getRuntime(), module, function, returnType, parameterTypes, convention, enums, false); }
public final NativeInvoker forceCompilation() { NativeInvoker invoker = null; while (!getJITHandle().compilationFailed() && (invoker = getJITHandle().compile(getImplementationClass(), function, signature, getName())) == null) ; return invoker; } }
@SuppressWarnings("deprecation") private static NativeDataConverter getParameterConverter(Signature signature, int i) { return signature.getParameterCount() > i ? DataConverters.getParameterConverter(signature.getParameterType(i), signature.getEnums()) : null; }
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); }
static NativeDataConverter getParameterConverter(Type type) { if (type instanceof MappedType) { return new MappedDataConverter((MappedType) type); } else if (type instanceof CallbackInfo) { return new CallbackDataConverter((CallbackInfo) type); } return null; }
@Override public DynamicMethod createDynamicMethod(RubyModule module) { return MethodFactory.createDynamicMethod(getRuntime(), module, function, functionInfo.returnType, functionInfo.parameterTypes, functionInfo.convention, enums, !saveError); }
final void free() { if ((flags & RELEASED) == 0) { flags = RELEASED | UNMANAGED; magazine.setFragmented(); dispose(); } } }
@SuppressWarnings("deprecation") private void setParameterConverterWithTypeAndSignature(Signature signature, boolean[] hasParameterConverter, int i, Type parameterType) { hasParameterConverter[i] = !(parameterType instanceof Type.Builtin) || DataConverters.isEnumConversionRequired(parameterType, signature.getEnums()); }
@Override public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name, IRubyObject[] args, Block block) { return getNativeInvoker().call(context, self, clazz, name, args, block); }
void dispose() { MemoryIO mem = getMemoryIO(); if (mem instanceof CallbackMemoryIO) { ((CallbackMemoryIO) mem).free(); } }
public void marshal(Invocation invocation, InvocationBuffer buffer, IRubyObject parameter) { ThreadContext context = invocation.getThreadContext(); final IRubyObject nativeValue = converter.toNative(context, parameter); // keep a hard ref to the converted value if needed if (converter.isReferenceRequired()) { invocation.addReference(nativeValue); } nativeMarshaller.marshal(context, buffer, nativeValue); }
public final NativeInvoker forceCompilation() { NativeInvoker invoker = null; while (!getJITHandle().compilationFailed() && (invoker = getJITHandle().compile(getImplementationClass(), function, signature, getName())) == null) ; return invoker; } }
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); }
static NativeDataConverter getParameterConverter(Type type) { if (type instanceof MappedType) { return new MappedDataConverter((MappedType) type); } else if (type instanceof CallbackInfo) { return new CallbackDataConverter((CallbackInfo) type); } return null; } static NativeDataConverter getParameterConverter(Type type, RubyHash enums) {
@Override public DynamicMethod createDynamicMethod(RubyModule module) { return MethodFactory.createDynamicMethod(getRuntime(), module, function, returnType, parameterTypes, convention, enums, false); }
public void marshal(Invocation invocation, InvocationBuffer buffer, IRubyObject parameter) { ThreadContext context = invocation.getThreadContext(); final IRubyObject nativeValue = converter.toNative(context, parameter); // keep a hard ref to the converted value if needed if (converter.isReferenceRequired()) { invocation.addReference(nativeValue); } nativeMarshaller.marshal(context, buffer, nativeValue); }
static NativeDataConverter getResultConverter(Type type) { if (type instanceof Type.Builtin) { return null; } else if (type instanceof MappedType) { return new MappedDataConverter((MappedType) type); } else if (type instanceof CallbackInfo) { return new CallbackDataConverter((CallbackInfo) type); } return null; }
public void marshal(Invocation invocation, InvocationBuffer buffer, IRubyObject parameter) { ThreadContext context = invocation.getThreadContext(); final IRubyObject nativeValue = converter.toNative(context, parameter); // keep a hard ref to the converted value if needed if (converter.isReferenceRequired()) { invocation.addReference(nativeValue); } nativeMarshaller.marshal(context, buffer, nativeValue); }