public IRubyObject afill(IRubyObject beginIndex, IRubyObject endIndex, IRubyObject value) { if (! (beginIndex instanceof RubyInteger)) { throw getRuntime().newTypeError(beginIndex, getRuntime().getInteger()); } int intIndex = (int) ((RubyInteger) beginIndex).getLongValue(); if (! (endIndex instanceof RubyInteger)) { throw getRuntime().newTypeError(endIndex, getRuntime().getInteger()); } int intEndIndex = (int) ((RubyInteger) endIndex).getLongValue(); if (! (value instanceof JavaObject)) { throw getRuntime().newTypeError("not a java object:" + value); } Object javaValue = ((JavaObject) value).getValue(); fillWithExceptionHandling(intIndex, intEndIndex, javaValue); return value; }
public IRubyObject afill(IRubyObject beginIndex, IRubyObject endIndex, IRubyObject value) { if (! (beginIndex instanceof RubyInteger)) { throw getRuntime().newTypeError(beginIndex, getRuntime().getInteger()); } int intIndex = (int) ((RubyInteger) beginIndex).getLongValue(); if (! (endIndex instanceof RubyInteger)) { throw getRuntime().newTypeError(endIndex, getRuntime().getInteger()); } int intEndIndex = (int) ((RubyInteger) endIndex).getLongValue(); if (! (value instanceof JavaObject)) { throw getRuntime().newTypeError("not a java object:" + value); } Object javaObject = ((JavaObject) value).getValue(); fillWithExceptionHandling(intIndex, intEndIndex, javaObject); return value; }
public IRubyObject afill(IRubyObject beginIndex, IRubyObject endIndex, IRubyObject value) { if (! (beginIndex instanceof RubyInteger)) { throw getRuntime().newTypeError(beginIndex, getRuntime().getInteger()); } int intIndex = (int) ((RubyInteger) beginIndex).getLongValue(); if (! (endIndex instanceof RubyInteger)) { throw getRuntime().newTypeError(endIndex, getRuntime().getInteger()); } int intEndIndex = (int) ((RubyInteger) endIndex).getLongValue(); if (! (value instanceof JavaObject)) { throw getRuntime().newTypeError("not a java object:" + value); } Object javaObject = ((JavaObject) value).getValue(); fillWithExceptionHandling(intIndex, intEndIndex, javaObject); return value; }
public IRubyObject afill(IRubyObject beginIndex, IRubyObject endIndex, IRubyObject value) { if (! (beginIndex instanceof RubyInteger)) { throw getRuntime().newTypeError(beginIndex, getRuntime().getInteger()); } int intIndex = (int) ((RubyInteger) beginIndex).getLongValue(); if (! (endIndex instanceof RubyInteger)) { throw getRuntime().newTypeError(endIndex, getRuntime().getInteger()); } int intEndIndex = (int) ((RubyInteger) endIndex).getLongValue(); if (! (value instanceof JavaObject)) { throw getRuntime().newTypeError("not a java object:" + value); } Object javaValue = ((JavaObject) value).getValue(); fillWithExceptionHandling(intIndex, intEndIndex, javaValue); return value; }
@JRubyMethod(name = "copy_data") public static IRubyObject copy_data(final ThreadContext context, final IRubyObject fromRuby, final IRubyObject toJava, final IRubyObject fillValue) { JavaArray javaArray = (JavaArray) toJava.dataGetStruct(); final int javaLength = javaArray.getLength(); final Class<?> targetType = javaArray.getComponentType(); Object fillJavaObject = null; if ( ! fillValue.isNil() ) fillJavaObject = fillValue.toJava(targetType); RubyArray rubyArray = null; if (fromRuby instanceof RubyArray) { rubyArray = (RubyArray) fromRuby; } else { fillJavaObject = fromRuby.toJava(targetType); } int i = 0; if ( rubyArray != null ) { final int rubyLength = rubyArray.getLength(); for (; i < rubyLength && i < javaLength; i++) { javaArray.setWithExceptionHandling(i, rubyArray.eltInternal(i).toJava(targetType)); } } if ( i < javaLength && fillJavaObject != null ) { javaArray.fillWithExceptionHandling(i, javaLength, fillJavaObject); } return toJava; }
@JRubyMethod(name = "copy_data") public static IRubyObject copy_data(final ThreadContext context, final IRubyObject fromRuby, final IRubyObject toJava, final IRubyObject fillValue) { JavaArray javaArray = (JavaArray) toJava.dataGetStruct(); final int javaLength = javaArray.getLength(); final Class<?> targetType = javaArray.getComponentType(); Object fillJavaObject = null; if ( ! fillValue.isNil() ) fillJavaObject = fillValue.toJava(targetType); RubyArray rubyArray = null; if (fromRuby instanceof RubyArray) { rubyArray = (RubyArray) fromRuby; } else { fillJavaObject = fromRuby.toJava(targetType); } int i = 0; if ( rubyArray != null ) { final int rubyLength = rubyArray.getLength(); for (; i < rubyLength && i < javaLength; i++) { javaArray.setWithExceptionHandling(i, rubyArray.eltInternal(i).toJava(targetType)); } } if ( i < javaLength && fillJavaObject != null ) { javaArray.fillWithExceptionHandling(i, javaLength, fillJavaObject); } return toJava; }
javaArrayJavaObj.fillWithExceptionHandling(i, javaLength, fillJavaObject);
javaArrayJavaObj.fillWithExceptionHandling(i, javaLength, fillJavaObject);