Class NativeClosureProxy

java.lang.Object
org.jruby.ext.ffi.jffi.NativeClosureProxy
All Implemented Interfaces:
com.kenai.jffi.Closure

final class NativeClosureProxy extends Object implements com.kenai.jffi.Closure
Wraps a ruby proc in a JFFI Closure
  • Field Details

  • Constructor Details

  • Method Details

    • invoke

      public void invoke(com.kenai.jffi.Closure.Buffer buffer)
      Specified by:
      invoke in interface com.kenai.jffi.Closure
    • invoke

      protected final void invoke(com.kenai.jffi.Closure.Buffer buffer, Object recv)
    • longValue

      private static final long longValue(IRubyObject value)
      Extracts the primitive value from a Ruby object. This is similar to Util.longValue(), except it won't throw exceptions for invalid values.
      Parameters:
      value - The Ruby object to convert
      Returns:
      a java long value.
    • addressValue

      private static final long addressValue(IRubyObject value)
      Extracts the primitive value from a Ruby object. This is similar to Util.longValue(), except it won't throw exceptions for invalid values.
      Parameters:
      value - The Ruby object to convert
      Returns:
      a java long value.
    • setReturnValue

      private static final void setReturnValue(Ruby runtime, Type type, com.kenai.jffi.Closure.Buffer buffer, IRubyObject value)
      Converts a ruby return value into a native callback return value.
      Parameters:
      runtime - The ruby runtime the callback is attached to
      type - The ruby type of the return value
      buffer - The native parameter buffer
      value - The ruby value
    • fromNative

      private static final IRubyObject fromNative(Ruby runtime, Type type, com.kenai.jffi.Closure.Buffer buffer, int index)
      Converts a native value into a ruby object.
      Parameters:
      runtime - The ruby runtime to create the ruby object in
      type - The type of the native parameter
      buffer - The JFFI Closure parameter buffer.
      index - The index of the parameter in the buffer.
      Returns:
      A new Ruby object.
    • getStringParameter

      private static final IRubyObject getStringParameter(Ruby runtime, com.kenai.jffi.Closure.Buffer buffer, int index)
      Converts a native string value into a ruby string object.
      Parameters:
      runtime - The ruby runtime to create the ruby string in
      buffer - The JFFI Closure parameter buffer.
      index - The index of the parameter in the buffer.
      Returns:
      A new Ruby string object or nil if string is NULL.