Skip to content

Commit

Permalink
Showing 151 changed files with 2,645 additions and 3,554 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -51,6 +51,8 @@ lib/ruby/stdlib/jar*
lib/ruby/stdlib/jline
lib/ruby/stdlib/jopenssl*
lib/ruby/stdlib/krypt*
lib/ruby/stdlib/net-telnet.rb
lib/ruby/stdlib/net/telnet*
lib/ruby/stdlib/openssl*
lib/ruby/stdlib/org/
lib/ruby/stdlib/readline/*readline*.jar
8 changes: 4 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -40,15 +40,14 @@ matrix:
include:
- env: COMMAND=test/check_versions.sh
jdk: oraclejdk8
- env: JT=check_ambiguous_arguments
- env: JT=check_ambiguous_arguments SKIP_BUILD=true
jdk: oraclejdk8
allow_failures:
- env: PHASE='-Prake -Dtask=test:mri:fullint'
- env: JT=check_ambiguous_arguments
jdk: oraclejdk8
- env: JT='test mri'
- env: PHASE='-Pj2ee --projects !truffle'
jdk: oraclejdk7
- env: JT='test integration long' JAVA_OPTS="$JAVA_OPTS -Xmx512m" HAS_REDIS=true
# NOTE: build seems to never start (waited for any to finish for more than a day) - probably a travis-ci bug
#- env: PHASE='-Pmain'
# sudo: required
@@ -66,7 +65,8 @@ branches:
- ruby-2.3

script: tool/travis_runner.sh
install: travis_retry ./mvnw -Pbootstrap clean install -B -Dinvoker.skip -Dmaven.test.skip
install:
- if [ -z "$SKIP_BUILD" ]; then travis_retry ./mvnw -Pbootstrap clean install -B -Dinvoker.skip -Dmaven.test.skip; fi

notifications:
irc:
5 changes: 2 additions & 3 deletions bin/rake
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@

require 'rubygems'

version = ">= 0"
version = ">= 0.a"

if ARGV.first
str = ARGV.first
@@ -19,5 +19,4 @@ if ARGV.first
end
end

gem 'rake', version
load Gem.bin_path('rake', 'rake', version)
load Gem.activate_bin_path('rake', 'rake', version)
5 changes: 2 additions & 3 deletions bin/rdoc
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@

require 'rubygems'

version = ">= 0"
version = ">= 0.a"

if ARGV.first
str = ARGV.first
@@ -19,5 +19,4 @@ if ARGV.first
end
end

gem 'rdoc', version
load Gem.bin_path('rdoc', 'rdoc', version)
load Gem.activate_bin_path('rdoc', 'rdoc', version)
5 changes: 2 additions & 3 deletions bin/ri
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@

require 'rubygems'

version = ">= 0"
version = ">= 0.a"

if ARGV.first
str = ARGV.first
@@ -19,5 +19,4 @@ if ARGV.first
end
end

gem 'rdoc', version
load Gem.bin_path('rdoc', 'ri', version)
load Gem.activate_bin_path('rdoc', 'ri', version)
10 changes: 8 additions & 2 deletions core/pom.rb
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@
'tzdata.version' => '2013d',
'tzdata.scope' => 'provided',

'unsafe.version' => '8.0',
'unsafe.version' => '8.92.1',
'unsafe.jar' => '${settings.localRepository}/com/headius/unsafe-mock/${unsafe.version}/unsafe-mock-${unsafe.version}.jar',

'maven.build.timestamp.format' => 'yyyy-MM-dd',
@@ -48,7 +48,7 @@
jar 'com.github.jnr:jnr-x86asm:1.0.2', :exclusions => ['com.github.jnr:jnr-ffi']
jar 'com.github.jnr:jnr-unixsocket:0.12', :exclusions => ['com.github.jnr:jnr-ffi']
jar 'com.github.jnr:jnr-posix:3.0.29', :exclusions => ['com.github.jnr:jnr-ffi']
jar 'com.github.jnr:jnr-constants:0.9.2-SNAPSHOT', :exclusions => ['com.github.jnr:jnr-ffi']
jar 'com.github.jnr:jnr-constants:0.9.2', :exclusions => ['com.github.jnr:jnr-ffi']
jar 'com.github.jnr:jnr-ffi:2.0.9'
jar 'com.github.jnr:jffi:${jffi.version}'
jar 'com.github.jnr:jffi:${jffi.version}:native'
@@ -251,6 +251,12 @@
target_path '${project.build.sourceDirectory}'
filtering 'true'
end

resource do
directory '${project.basedir}/..'
includes [ 'BSDL', 'COPYING', 'LEGAL', 'LICENSE.RUBY' ]
target_path '${project.build.outputDirectory}/META-INF/'
end
end


14 changes: 12 additions & 2 deletions core/pom.xml
Original file line number Diff line number Diff line change
@@ -41,7 +41,7 @@ DO NOT MODIFIY - GENERATED CODE
<jruby.launch.memory>1024M</jruby.launch.memory>
<jruby.compile.memory>2G</jruby.compile.memory>
<version.ruby.major>2.3</version.ruby.major>
<unsafe.version>8.0</unsafe.version>
<unsafe.version>8.92.1</unsafe.version>
<release.dir>release</release.dir>
<lib.dir>lib</lib.dir>
<rails.dir>${test.dir}/rails</rails.dir>
@@ -147,7 +147,7 @@ DO NOT MODIFIY - GENERATED CODE
<dependency>
<groupId>com.github.jnr</groupId>
<artifactId>jnr-constants</artifactId>
<version>0.9.2-SNAPSHOT</version>
<version>0.9.2</version>
<exclusions>
<exclusion>
<artifactId>jnr-ffi</artifactId>
@@ -300,6 +300,16 @@ DO NOT MODIFIY - GENERATED CODE
<include>${Constants.java}</include>
</includes>
</resource>
<resource>
<targetPath>${project.build.outputDirectory}/META-INF/</targetPath>
<directory>${project.basedir}/..</directory>
<includes>
<include>BSDL</include>
<include>COPYING</include>
<include>LEGAL</include>
<include>LICENSE.RUBY</include>
</includes>
</resource>
</resources>
<pluginManagement>
<plugins>
84 changes: 84 additions & 0 deletions core/src/main/java/org/jruby/RubyArray.java
Original file line number Diff line number Diff line change
@@ -4198,6 +4198,90 @@ final IRubyObject dig(ThreadContext context, IRubyObject[] args, int idx) {
return idx == args.length ? val : RubyObject.dig(context, val, args, idx);
}

@JRubyMethod(name = "max")
public IRubyObject max(ThreadContext context, Block block) {
// TODO: check for overwritten <=> on Fixnum and String
// struct cmp_opt_data cmp_opt = { 0, 0 };
IRubyObject result = UNDEF, v;
int i;

if (block.isGiven()) {
for (i = 0; i < realLength; i++) {
v = eltOk(i);
if (result == UNDEF || RubyComparable.cmpint(context, block.yieldSpecific(context, v, result), v, result) > 0) {
result = v;
}
}
} else {
for (i = 0; i < realLength; i++) {
v = eltOk(i);
if (result == UNDEF || optimizedCmp(context, v, result/*, cmp_opt*/) > 0) {
result = v;
}
}
}
if (result == UNDEF) return context.nil;
return result;
}

@JRubyMethod(name = "max")
public IRubyObject max(ThreadContext context, IRubyObject num, Block block) {
if (!num.isNil()) {
return RubyEnumerable.max(context, this, num, block);
}

return max(context, block);
}

@JRubyMethod(name = "min")
public IRubyObject min(ThreadContext context, Block block) {
// TODO: check for overwritten <=> on Fixnum and String
// struct cmp_opt_data cmp_opt = { 0, 0 };
IRubyObject result = UNDEF, v;
int i;

if (block.isGiven()) {
for (i = 0; i < realLength; i++) {
v = eltOk(i);
if (result == UNDEF || RubyComparable.cmpint(context, block.yieldSpecific(context, v, result), v, result) < 0) {
result = v;
}
}
}
else {
for (i = 0; i < realLength; i++) {
v = eltOk(i);
if (result == UNDEF || optimizedCmp(context, v, result/*, cmp_opt*/) < 0) {
result = v;
}
}
}
if (result == UNDEF) return context.nil;
return result;
}

@JRubyMethod(name = "min")
public IRubyObject min(ThreadContext context, IRubyObject num, Block block) {
if (!num.isNil()) {
return RubyEnumerable.min(context, this, num, block);
}

return min(context, block);
}

private static final int optimizedCmp(ThreadContext context, IRubyObject a, IRubyObject b/*, IRubyObject data*/) {
// TODO: check for overwritten <=> on Fixnum and String
if (a instanceof RubyFixnum && b instanceof RubyFixnum /*&& CMP_OPTIMIZABLE(data, Fixnum)*/) {
long aLong = ((RubyFixnum)a).getLongValue();
long bLong = ((RubyFixnum)b).getLongValue();
return aLong > bLong ? 1 : aLong < bLong ? -1 : 0;
} else if (a instanceof RubyString && b instanceof RubyString /*&& CMP_OPTIMIZABLE(data, String)*/) {
return ((RubyString)a).op_cmp((RubyString)b);
}

return RubyComparable.cmpint(context, invokedynamic(context, a, OP_CMP, b), a, b);
}

@Override
public Class getJavaClass() {
return List.class;
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/RubyFixnum.java
Original file line number Diff line number Diff line change
@@ -1194,7 +1194,7 @@ public IRubyObject succ(ThreadContext context) {
public IRubyObject bit_length(ThreadContext context) {
long tmpValue = value;
if (value < 0) {
tmpValue = Math.abs(value);
tmpValue = ~value;
}

return context.runtime.newFixnum(64 - Long.numberOfLeadingZeros(tmpValue));
85 changes: 51 additions & 34 deletions core/src/main/java/org/jruby/RubyStruct.java
Original file line number Diff line number Diff line change
@@ -229,40 +229,8 @@ public static RubyClass newInstance(IRubyObject recv, IRubyObject[] args, Block
final String memberName = args[i].asJavaString();
// if we are storing a name as well, index is one too high for values
final int index = (name == null && !nilName) ? i : i - 1;
newStruct.addMethod(memberName, new DynamicMethod(newStruct, Visibility.PUBLIC) {
@Override
public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name, IRubyObject[] args, Block block) {
Arity.checkArgumentCount(context.runtime, name, args, 0, 0);
return ((RubyStruct)self).get(index);
}

@Override
public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name) {
return ((RubyStruct)self).get(index);
}

@Override
public DynamicMethod dup() {
return this;
}
});
newStruct.addMethod(memberName + '=', new DynamicMethod(newStruct, Visibility.PUBLIC) {
@Override
public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name, IRubyObject[] args, Block block) {
Arity.checkArgumentCount(context.runtime, name, args, 1, 1);
return ((RubyStruct)self).set(args[0], index);
}

@Override
public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name, IRubyObject arg) {
return ((RubyStruct)self).set(arg, index);
}

@Override
public DynamicMethod dup() {
return this;
}
});
newStruct.addMethod(memberName, new Accessor(newStruct, index));
newStruct.addMethod(memberName + '=', new Mutator(newStruct, index));
}

if (block.isGiven()) {
@@ -849,4 +817,53 @@ public IRubyObject initialize_copy(IRubyObject arg) {
return this;
}

private static class Accessor extends DynamicMethod {
private final int index;

public Accessor(RubyClass newStruct, int index) {
super(newStruct, Visibility.PUBLIC);
this.index = index;
}

@Override
public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name, IRubyObject[] args, Block block) {
Arity.checkArgumentCount(context.runtime, name, args, 0, 0);
return ((RubyStruct)self).get(index);
}

@Override
public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name) {
return ((RubyStruct)self).get(index);
}

@Override
public DynamicMethod dup() {
return new Accessor((RubyClass) getImplementationClass(), index);
}
}

private static class Mutator extends DynamicMethod {
private final int index;

public Mutator(RubyClass newStruct, int index) {
super(newStruct, Visibility.PUBLIC);
this.index = index;
}

@Override
public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name, IRubyObject[] args, Block block) {
Arity.checkArgumentCount(context.runtime, name, args, 1, 1);
return ((RubyStruct)self).set(args[0], index);
}

@Override
public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name, IRubyObject arg) {
return ((RubyStruct)self).set(arg, index);
}

@Override
public DynamicMethod dup() {
return new Accessor((RubyClass) getImplementationClass(), index);
}
}
}
4 changes: 2 additions & 2 deletions core/src/main/java/org/jruby/ext/ffi/AbstractMemory.java
Original file line number Diff line number Diff line change
@@ -380,7 +380,7 @@ public IRubyObject get_uint8(ThreadContext context, IRubyObject offset) {
* @param value The value to write.
* @return The value written.
*/
@JRubyMethod(name = { "write_short" }, required = 1)
@JRubyMethod(name = { "write_short", "write_int16" }, required = 1)
public IRubyObject write_short(ThreadContext context, IRubyObject value) {
getMemoryIO().putShort(0, Util.int16Value(value));

@@ -522,7 +522,7 @@ public IRubyObject get_uint16(ThreadContext context, IRubyObject offset) {
* @param value The value to write.
* @return The value written.
*/
@JRubyMethod(name = { "write_int" })
@JRubyMethod(name = { "write_int", "write_int32" })
public IRubyObject write_int(ThreadContext context, IRubyObject value) {
getMemoryIO().putInt(0, Util.int32Value(value));

13 changes: 4 additions & 9 deletions core/src/main/java/org/jruby/ext/socket/RubyUDPSocket.java
Original file line number Diff line number Diff line change
@@ -28,6 +28,7 @@
package org.jruby.ext.socket;

import java.io.IOException;
import java.net.BindException;
import java.net.ConnectException;
import java.net.InetAddress;
import java.net.InetSocketAddress;
@@ -159,6 +160,9 @@ else if (host instanceof RubyFixnum) {
catch (UnknownHostException e) {
throw SocketUtils.sockerr(runtime, "bind: name or service not known");
}
catch (BindException e) {
throw runtime.newErrnoEADDRFromBindException(e);
}
catch (SocketException e) {
final String message = e.getMessage();
if ( message != null ) {
@@ -172,15 +176,6 @@ else if (host instanceof RubyFixnum) {
catch (IOException e) {
throw sockerr(runtime, "bind: name or service not known", e);
}
//catch (Error e) {
// // Workaround for a bug in Sun's JDK 1.5.x, see
// // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6303753
// if (e.getCause() instanceof SocketException) {
// throw SocketUtils.sockerr(runtime, "bind: name or service not known");
// } else {
// throw e;
// }
//}
}

@JRubyMethod
Loading

0 comments on commit 9a73369

Please sign in to comment.