All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jruby.ext.ffi.jffi.DefaultMethodZeroArg Maven / Gradle / Ivy

There is a newer version: 9.4.9.0
Show newest version

package org.jruby.ext.ffi.jffi;

import com.kenai.jffi.Function;
import com.kenai.jffi.HeapInvocationBuffer;
import org.jruby.RubyModule;
import org.jruby.runtime.Arity;
import org.jruby.runtime.Block;
import org.jruby.runtime.ThreadContext;
import org.jruby.runtime.builtin.IRubyObject;

class DefaultMethodZeroArg extends JFFIDynamicMethod {
    private final HeapInvocationBuffer dummyBuffer;

    public DefaultMethodZeroArg(RubyModule implementationClass, Function function, FunctionInvoker functionInvoker) {
        super(implementationClass, Arity.NO_ARGUMENTS, function, functionInvoker);
        dummyBuffer = new HeapInvocationBuffer(function);
    }

    @Override
    public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name, IRubyObject[] args, Block block) {
        arity.checkArity(context.getRuntime(), args);
        return functionInvoker.invoke(context, function, dummyBuffer);
    }

    @Override
    public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule klazz, String name) {
        return functionInvoker.invoke(context, function, dummyBuffer);
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy