@JRubyMethod(
     name = {"create_invoker", "createInvoker"},
     required = 5)
 public IRubyObject createInvoker(ThreadContext context, IRubyObject[] args) {
   RubyArray paramTypes = (RubyArray) args[3];
   NativeParam[] nativeParamTypes = new NativeParam[paramTypes.size()];
   for (int i = 0; i < paramTypes.size(); ++i) {
     IRubyObject obj = (IRubyObject) paramTypes.entry(i);
     if (obj instanceof NativeParam) {
       nativeParamTypes[i] = (NativeParam) obj;
     } else if (obj instanceof RubyInteger) {
       nativeParamTypes[i] = NativeType.valueOf(Util.int32Value(obj));
     } else {
       context.getRuntime().newArgumentError("Invalid parameter type");
     }
   }
   try {
     return createInvoker(
         context.getRuntime(),
         args[0].isNil() ? null : args[0].toString(),
         args[1].toString(),
         NativeType.valueOf(Util.int32Value(args[2])),
         nativeParamTypes,
         args[4].toString());
   } catch (UnsatisfiedLinkError ex) {
     return context.getRuntime().getNil();
   }
 }
Exemple #2
0
 private final long getOffset(IRubyObject index) {
   return getOffset(Util.int32Value(index));
 }
 public final void marshal(
     Invocation invocation, InvocationBuffer buffer, IRubyObject parameter) {
   buffer.putInt(Util.int32Value(parameter));
 }
 public final void marshal(
     ThreadContext context, InvocationBuffer buffer, IRubyObject parameter) {
   buffer.putInt(Util.int32Value(parameter));
 }
 public final int intValue(ThreadContext context, IRubyObject obj) {
   return Util.int32Value(obj);
 }
 @JRubyMethod(name = {"error=", "last_error="})
 public IRubyObject getLastError(ThreadContext context, IRubyObject error) {
   setLastError(Util.int32Value(error));
   return context.getRuntime().getNil();
 }