Skip to content

Commit

Permalink
Merge branch 'master' into truffle-head
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisseaton committed Feb 10, 2015
2 parents 80340fe + 92e4062 commit 87b9356
Show file tree
Hide file tree
Showing 219 changed files with 4,859 additions and 1,625 deletions.
15 changes: 8 additions & 7 deletions COPYING
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,14 @@ lib/ruby/1.9, and lib/ruby/site_ruby/1.8/rubygems*.
The "yecht" library is Copyright (c) 2009-2011 Ola Bini, and released
under the MIT license.

The Rubinius API implementation in core/src/main/ruby/jruby/truffle/core/rubinius/api
and core/src/main/java/org/jruby/truffle/runtime/rubinius is copyright (c) 2011,
Evan Phoenix, and released under the 3-clause BSD license.

The Rubinius core library implementation in core/src/main/ruby/jruby/truffle/core/rubinius/kernel
is copyright (c) 2007-2014, Evan Phoenix and contributors, and released under
the 3-clause BSD license.
The Rubinius API implementation in truffle/src/main/ruby/core/rubinius/api
is copyright (c) 2011, Evan Phoenix, and released under the 3-clause BSD license.

The Rubinius core library implementation
in truffle/src/main/ruby/core/rubinius/bootstrap
and truffle/src/main/ruby/core/rubinius/common is
copyright (c) 2007-2014, Evan Phoenix and contributors,
and released under the 3-clause BSD license.

The complete text of the Eclipse Public License is as follows:

Expand Down
12 changes: 6 additions & 6 deletions antlib/extra.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ build jruby-complete.jar
<env key='GEM_PATH' value='lib/ruby/gems/shared'/>
<arg value='-Djruby.home=uri:classloader://META-INF/jruby.home'/>
<arg value='-cp'/>
<arg value='core/target/test-classes:test/target/test-classes:lib/jruby.jar:maven/jruby-stdlib/target/jruby-stdlib-1.7.19-SNAPSHOT.jar'/>
<arg value='core/target/test-classes:test/target/test-classes:lib/jruby.jar:maven/jruby-stdlib/target/jruby-stdlib-1.7.20-SNAPSHOT.jar'/>
<arg value='org.jruby.Main'/>
<arg value='-I.:test/externals/ruby1.9:test/externals/ruby1.9/ruby'/>
<arg value='-r./test/ruby19_env.rb'/>
Expand Down Expand Up @@ -137,7 +137,7 @@ build jruby-complete.jar
<env key='GEM_PATH' value='lib/ruby/gems/shared'/>
<arg value='-Djruby.home=uri:classloader://META-INF/jruby.home'/>
<arg value='-cp'/>
<arg value='core/target/test-classes:test/target/test-classes:maven/jruby-complete/target/jruby-complete-1.7.19-SNAPSHOT.jar'/>
<arg value='core/target/test-classes:test/target/test-classes:maven/jruby-complete/target/jruby-complete-1.7.20-SNAPSHOT.jar'/>
<arg value='org.jruby.Main'/>
<arg value='-I.:test/externals/ruby1.9:test/externals/ruby1.9/ruby'/>
<arg value='-r./test/ruby19_env.rb'/>
Expand All @@ -153,7 +153,7 @@ build jruby-complete.jar
<env key='GEM_PATH' value='lib/ruby/gems/shared'/>
<arg value='-Djruby.home=uri:classloader://META-INF/jruby.home'/>
<arg value='-cp'/>
<arg value='core/target/test-classes:test/target/test-classes:lib/jruby.jar:maven/jruby-stdlib/target/jruby-stdlib-1.7.19-SNAPSHOT.jar'/>
<arg value='core/target/test-classes:test/target/test-classes:lib/jruby.jar:maven/jruby-stdlib/target/jruby-stdlib-1.7.20-SNAPSHOT.jar'/>
<arg value='org.jruby.Main'/>
<arg value='-I.:test/externals/ruby1.9:test/externals/ruby1.9/ruby'/>
<arg value='-r./test/ruby19_env.rb'/>
Expand All @@ -169,7 +169,7 @@ build jruby-complete.jar
<env key='GEM_PATH' value='lib/ruby/gems/shared'/>
<arg value='-Djruby.home=uri:classloader://META-INF/jruby.home'/>
<arg value='-cp'/>
<arg value='core/target/test-classes:test/target/test-classes:lib/jruby.jar:maven/jruby-stdlib/target/jruby-stdlib-1.7.19-SNAPSHOT.jar'/>
<arg value='core/target/test-classes:test/target/test-classes:lib/jruby.jar:maven/jruby-stdlib/target/jruby-stdlib-1.7.20-SNAPSHOT.jar'/>
<arg value='org.jruby.Main'/>
<arg value='-I.:test/externals/ruby1.9:test/externals/ruby1.9/ruby'/>
<arg value='-r./test/ruby19_env.rb'/>
Expand Down Expand Up @@ -461,7 +461,7 @@ build jruby-complete.jar
<env key='GEM_PATH' value='lib/ruby/gems/shared'/>
<arg value='-Djruby.home=uri:classloader://META-INF/jruby.home'/>
<arg value='-cp'/>
<arg value='core/target/test-classes:test/target/test-classes:maven/jruby-complete/target/jruby-complete-1.7.19-SNAPSHOT.jar'/>
<arg value='core/target/test-classes:test/target/test-classes:maven/jruby-complete/target/jruby-complete-1.7.20-SNAPSHOT.jar'/>
<arg value='org.jruby.Main'/>
<arg value='-I.:test/externals/ruby1.9:test/externals/ruby1.9/ruby'/>
<arg value='-r./test/ruby19_env.rb'/>
Expand Down Expand Up @@ -515,4 +515,4 @@ build jruby-complete.jar
<!--arg value='-v'/-->
</exec>
</target>
<target description='test using jruby-complete or jruby-core/jruby-stdlib jars' name='test-jruby-jars' depends='mvn,test-jruby-jars-jruby.1.9,test-jruby-complete-slow,test-jruby-jars-objectspace,test-jruby-jars-mri.1.9,test-jruby-complete-rubicon.1.9'/></project>
<target description='test using jruby-complete or jruby-core/jruby-stdlib jars' name='test-jruby-jars' depends='mvn,test-jruby-jars-jruby.1.9,test-jruby-complete-slow,test-jruby-jars-objectspace,test-jruby-jars-mri.1.9,test-jruby-complete-rubicon.1.9'/></project>
28 changes: 18 additions & 10 deletions core/src/main/java/org/jruby/RubyDir.java
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,9 @@ private static IRubyObject asRubyStringList(Ruby runtime, List<ByteList> dirs) {
}

private static String getCWD(Ruby runtime) {
if (runtime.getCurrentDirectory().startsWith("uri:")) {
return runtime.getCurrentDirectory();
}
try {
return new org.jruby.util.NormalizedFile(runtime.getCurrentDirectory()).getCanonicalPath();
} catch (Exception e) {
Expand Down Expand Up @@ -297,17 +300,22 @@ public static IRubyObject chdir(ThreadContext context, IRubyObject recv, IRubyOb
RubyFile.get_path(context, args[0]) : getHomeDirectoryPath(context);
String adjustedPath = RubyFile.adjustRootPathOnWindows(runtime, path.asJavaString(), null);
checkDirIsTwoSlashesOnWindows(runtime, adjustedPath);
JRubyFile dir = getDir(runtime, adjustedPath, true);
String realPath;
String realPath = null;
String oldCwd = runtime.getCurrentDirectory();
if (adjustedPath.startsWith("uri:")){
realPath = adjustedPath;
}
else {
JRubyFile dir = getDir(runtime, adjustedPath, true);

// We get canonical path to try and flatten the path out.
// a dir '/subdir/..' should return as '/'
// cnutter: Do we want to flatten path out?
try {
realPath = dir.getCanonicalPath();
} catch (IOException e) {
realPath = dir.getAbsolutePath();
// We get canonical path to try and flatten the path out.
// a dir '/subdir/..' should return as '/'
// cnutter: Do we want to flatten path out?
try {
realPath = dir.getCanonicalPath();
} catch (IOException e) {
realPath = dir.getAbsolutePath();
}
}

IRubyObject result = null;
Expand All @@ -317,7 +325,7 @@ public static IRubyObject chdir(ThreadContext context, IRubyObject recv, IRubyOb
try {
result = block.yield(context, path);
} finally {
getDir(runtime, oldCwd, true); // ENEBO: Needed in case exception is thrown???
getDir(runtime, oldCwd, true); // needed in case the block deleted the oldCwd
runtime.setCurrentDirectory(oldCwd);
}
} else {
Expand Down
12 changes: 9 additions & 3 deletions core/src/main/java/org/jruby/RubyString.java
Original file line number Diff line number Diff line change
Expand Up @@ -5804,11 +5804,17 @@ public static ByteList encodeBytelist(CharSequence value, Encoding encoding) {
public Object toJava(Class target) {
if (target.isAssignableFrom(String.class)) {
return decodeString();
} else if (target.isAssignableFrom(ByteList.class)) {
}
if (target.isAssignableFrom(ByteList.class)) {
return value;
} else {
return super.toJava(target);
}
if (target == Character.class || target == Character.TYPE) {
if ( strLength() != 1 ) {
throw getRuntime().newArgumentError("could not coerce string of length " + strLength() + " (!= 1) into a char");
}
return decodeString().charAt(0);
}
return super.toJava(target);
}

/**
Expand Down
24 changes: 12 additions & 12 deletions core/src/main/java/org/jruby/RubyStruct.java
Original file line number Diff line number Diff line change
Expand Up @@ -547,37 +547,37 @@ public IRubyObject call(IRubyObject obj, boolean recur) {
private IRubyObject inspectStruct(final ThreadContext context, boolean recur) {
Ruby runtime = context.runtime;
RubyArray member = __member__();
ByteList buffer = new ByteList("#<struct ".getBytes());
RubyString buffer = RubyString.newString(getRuntime(), new ByteList("#<struct ".getBytes()));
String cpath = getMetaClass().getRealClass().getName();
char first = cpath.charAt(0);

if (recur || first != '#') {
buffer.append(cpath.getBytes());
buffer.append(' ');
buffer.cat(cpath.getBytes());
buffer.cat(' ');
}

if (recur) {
buffer.append(":...>".getBytes());
return runtime.newString(buffer);
buffer.cat(":...>".getBytes());
return buffer.dup();
}

for (int i = 0,k=member.getLength(); i < k; i++) {
if (i > 0) {
buffer.append(',').append(' ');
buffer.cat(',').cat(' ');
}
RubySymbol slot = (RubySymbol)member.eltInternal(i);
String name = slot.toString();
if (IdUtil.isLocal(name) || IdUtil.isConstant(name)) {
buffer.append(RubyString.objAsString(context, slot).getByteList());
buffer.cat19(RubyString.objAsString(context, slot));
} else {
buffer.append(((RubyString) slot.inspect(context)).getByteList());
buffer.cat19(((RubyString) slot.inspect(context)));
}
buffer.append('=');
buffer.append(inspect(context, values[i]).getByteList());
buffer.cat('=');
buffer.cat19(inspect(context, values[i]));
}

buffer.append('>');
return getRuntime().newString(buffer); // OBJ_INFECT
buffer.cat('>');
return buffer.dup(); // OBJ_INFECT
}