Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Bump up execution mode and stdlib to 2.1 (head).
  • Loading branch information
headius committed Oct 8, 2013
1 parent 104b6ee commit 6d5ddac
Show file tree
Hide file tree
Showing 1,170 changed files with 11,702 additions and 133,756 deletions.
7 changes: 4 additions & 3 deletions core/src/main/java/org/jruby/CompatVersion.java
Expand Up @@ -2,14 +2,14 @@

public enum CompatVersion {

RUBY1_8, RUBY1_9, RUBY2_0, BOTH;
RUBY1_8, RUBY1_9, RUBY2_0, RUBY2_1, BOTH;

public boolean is1_9() {
return this == RUBY1_9 || this == RUBY2_0;
return this == RUBY1_9 || this == RUBY2_0 || this == RUBY2_1;
}

public boolean is2_0() {
return this == RUBY2_0;
return this == RUBY2_0 || this == RUBY2_1;
}

public static CompatVersion getVersionFromString(String compatString) {
Expand All @@ -34,6 +34,7 @@ public static boolean shouldBindMethod(CompatVersion runtimeVersion, CompatVersi
if (runtimeVersion == RUBY1_8) return methodVersion == RUBY1_8 || methodVersion == BOTH;
if (runtimeVersion == RUBY1_9) return methodVersion == RUBY1_9 || methodVersion == BOTH;
if (runtimeVersion == RUBY2_0) return methodVersion == RUBY1_9 || methodVersion == RUBY2_0 || methodVersion == BOTH;
if (runtimeVersion == RUBY2_1) return methodVersion == RUBY1_9 || methodVersion == RUBY2_0 || methodVersion == RUBY2_1 || methodVersion == BOTH;
return false;
}
}
10 changes: 1 addition & 9 deletions core/src/main/java/org/jruby/Ruby.java
Expand Up @@ -1681,15 +1681,7 @@ private void initRubyKernel() {

// load Ruby parts of core
loadService.loadFromClassLoader(getClassLoader(), "jruby/kernel.rb", false);

switch (config.getCompatVersion()) {
case RUBY1_9:
loadService.loadFromClassLoader(getClassLoader(), "jruby/kernel19.rb", false);
break;
case RUBY2_0:
loadService.loadFromClassLoader(getClassLoader(), "jruby/kernel20.rb", false);
break;
}
loadService.loadFromClassLoader(getClassLoader(), "jruby/kernel21.rb", false);
}

private void addLazyBuiltin(String name, String shortName, String className) {
Expand Down
19 changes: 3 additions & 16 deletions core/src/main/java/org/jruby/RubyGlobal.java
Expand Up @@ -109,21 +109,8 @@ public static void createGlobals(ThreadContext context, Ruby runtime) {
IRubyObject platform = runtime.newString(Constants.PLATFORM).freeze(context);
IRubyObject engine = runtime.newString(Constants.ENGINE).freeze(context);

switch (runtime.getInstanceConfig().getCompatVersion()) {
case RUBY1_8:
version = runtime.newString(Constants.RUBY_VERSION).freeze(context);
patchlevel = runtime.newFixnum(Constants.RUBY_PATCHLEVEL);
runtime.defineGlobalConstant("VERSION", version);
break;
case RUBY1_9:
version = runtime.newString(Constants.RUBY1_9_VERSION).freeze(context);
patchlevel = runtime.newFixnum(Constants.RUBY1_9_PATCHLEVEL);
break;
case RUBY2_0:
version = runtime.newString(Constants.RUBY2_0_VERSION).freeze(context);
patchlevel = runtime.newFixnum(Constants.RUBY2_0_PATCHLEVEL);
break;
}
version = runtime.newString(Constants.RUBY_VERSION).freeze(context);
patchlevel = runtime.newFixnum(Constants.RUBY_PATCHLEVEL);
runtime.defineGlobalConstant("RUBY_VERSION", version);
runtime.defineGlobalConstant("RUBY_PATCHLEVEL", patchlevel);
runtime.defineGlobalConstant("RUBY_RELEASE_DATE", release);
Expand All @@ -145,7 +132,7 @@ public static void createGlobals(ThreadContext context, Ruby runtime) {
runtime.defineGlobalConstant("JRUBY_REVISION", jrubyRevision);

// needs to be a fixnum, but our revision is a sha1 hash from git
runtime.defineGlobalConstant("RUBY_REVISION", runtime.newFixnum(Constants.RUBY2_0_REVISION));
runtime.defineGlobalConstant("RUBY_REVISION", runtime.newFixnum(Constants.RUBY_REVISION));

RubyInstanceConfig.Verbosity verbosity = runtime.getInstanceConfig().getVerbosity();
runtime.defineVariable(new WarningGlobalVariable(runtime, "$-W", verbosity), GLOBAL);
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/RubyInstanceConfig.java
Expand Up @@ -83,7 +83,7 @@ public class RubyInstanceConfig {
public RubyInstanceConfig() {
currentDirectory = Ruby.isSecurityRestricted() ? "/" : JRubyFile.getFileProperty("user.dir");

compatVersion = CompatVersion.RUBY2_0;
compatVersion = CompatVersion.RUBY2_1;

if (Ruby.isSecurityRestricted()) {
compileMode = CompileMode.OFF;
Expand Down
28 changes: 4 additions & 24 deletions core/src/main/java/org/jruby/anno/AnnotationBinder.java
Expand Up @@ -143,8 +143,6 @@ public void processType(TypeElement cd) {

Map<CharSequence, List<ExecutableElement>> annotatedMethods = new HashMap<CharSequence, List<ExecutableElement>>();
Map<CharSequence, List<ExecutableElement>> staticAnnotatedMethods = new HashMap<CharSequence, List<ExecutableElement>>();
Map<CharSequence, List<ExecutableElement>> annotatedMethods1_8 = new HashMap<CharSequence, List<ExecutableElement>>();
Map<CharSequence, List<ExecutableElement>> staticAnnotatedMethods1_8 = new HashMap<CharSequence, List<ExecutableElement>>();
Map<CharSequence, List<ExecutableElement>> annotatedMethods1_9 = new HashMap<CharSequence, List<ExecutableElement>>();
Map<CharSequence, List<ExecutableElement>> staticAnnotatedMethods1_9 = new HashMap<CharSequence, List<ExecutableElement>>();
Map<CharSequence, List<ExecutableElement>> annotatedMethods2_0 = new HashMap<CharSequence, List<ExecutableElement>>();
Expand Down Expand Up @@ -179,7 +177,8 @@ public void processType(TypeElement cd) {
Map<CharSequence, List<ExecutableElement>> methodsHash = null;
if (method.getModifiers().contains(Modifier.STATIC)) {
if (anno.compat() == CompatVersion.RUBY1_8) {
methodsHash = staticAnnotatedMethods1_8;
// skip 1.8 methods
continue;
} else if (anno.compat() == CompatVersion.RUBY1_9) {
methodsHash = staticAnnotatedMethods1_9;
} else if (anno.compat() == CompatVersion.RUBY2_0) {
Expand All @@ -189,7 +188,8 @@ public void processType(TypeElement cd) {
}
} else {
if (anno.compat() == CompatVersion.RUBY1_8) {
methodsHash = annotatedMethods1_8;
// skip 1.8 methods
continue;
} else if (anno.compat() == CompatVersion.RUBY1_9) {
methodsHash = annotatedMethods1_9;
} else if (anno.compat() == CompatVersion.RUBY2_0) {
Expand Down Expand Up @@ -246,16 +246,6 @@ public void processType(TypeElement cd) {
if (!decl.getAnnotation(JRubyMethod.class).omit()) addCoreMethodMapping(entry.getKey(), decl, out);
}

if (!staticAnnotatedMethods1_8.isEmpty()) {
out.println(" if (compatVersion == CompatVersion.RUBY1_8 || compatVersion == CompatVersion.BOTH) {");
processMethodDeclarations(staticAnnotatedMethods1_8);
for (Map.Entry<CharSequence, List<ExecutableElement>> entry : staticAnnotatedMethods1_8.entrySet()) {
ExecutableElement decl = entry.getValue().get(0);
if (!decl.getAnnotation(JRubyMethod.class).omit()) addCoreMethodMapping(entry.getKey(), decl, out);
}
out.println(" }");
}

if (!staticAnnotatedMethods1_9.isEmpty()) {
out.println(" if (compatVersion.is1_9() || compatVersion == CompatVersion.BOTH) {");
processMethodDeclarations(staticAnnotatedMethods1_9);
Expand All @@ -282,16 +272,6 @@ public void processType(TypeElement cd) {
if (!decl.getAnnotation(JRubyMethod.class).omit()) addCoreMethodMapping(entry.getKey(), decl, out);
}

if (!annotatedMethods1_8.isEmpty()) {
out.println(" if (compatVersion == CompatVersion.RUBY1_8 || compatVersion == CompatVersion.BOTH) {");
processMethodDeclarations(annotatedMethods1_8);
for (Map.Entry<CharSequence, List<ExecutableElement>> entry : annotatedMethods1_8.entrySet()) {
ExecutableElement decl = entry.getValue().get(0);
if (!decl.getAnnotation(JRubyMethod.class).omit()) addCoreMethodMapping(entry.getKey(), decl, out);
}
out.println(" }");
}

if (!annotatedMethods1_9.isEmpty()) {
out.println(" if (compatVersion.is1_9() || compatVersion == CompatVersion.BOTH) {");
processMethodDeclarations(annotatedMethods1_9);
Expand Down
Expand Up @@ -109,7 +109,7 @@ public static String getArchitecture() {
}

public static String getRuntimeVerStr(Ruby runtime) {
return "1.9";
return "2.1";
}

public static String getNormalizedHome(Ruby runtime) {
Expand Down
1 change: 0 additions & 1 deletion core/src/main/java/org/jruby/runtime/load/LoadService.java
Expand Up @@ -250,7 +250,6 @@ public void init(List prependDirectories) {
}
addPath(RbConfigLibrary.getRubySharedLibDir(runtime));
// TODO: merge
addPath(RbConfigLibrary.getRubyLibDirFor(runtime, "2.0"));
addPath(RbConfigLibrary.getRubyLibDir(runtime));
}

Expand Down
22 changes: 5 additions & 17 deletions core/src/main/java/org/jruby/util/cli/OutputStrings.java
Expand Up @@ -108,23 +108,11 @@ public static String getVersionString(CompatVersion compatVersion) {
String patchDelimeter = "p";
int patchlevel;
String versionString = "";
switch (compatVersion) {
case RUBY1_8:
ver = Constants.RUBY_VERSION;
patchlevel = Constants.RUBY_PATCHLEVEL;
versionString = String.format("ruby-%s%s%d", ver, patchDelimeter, patchlevel);
break;
case RUBY1_9:
ver = Constants.RUBY1_9_VERSION;
patchlevel = Constants.RUBY1_9_PATCHLEVEL;
versionString = String.format("%s%s%d", ver, patchDelimeter, patchlevel);
break;
case RUBY2_0:
ver = Constants.RUBY2_0_VERSION;
patchlevel = Constants.RUBY2_0_PATCHLEVEL;
versionString = String.format("%s%s%d", ver, patchDelimeter, patchlevel);
break;
}
ver = Constants.RUBY_VERSION;
patchlevel = Constants.RUBY_PATCHLEVEL;
// TODO: add patchlevel once 2.1 is released
// versionString = String.format("%s%s%d", ver, patchDelimeter, patchlevel);
versionString = String.format("%s", ver);

String fullVersion = String.format(
"jruby %s (%s) %s %s on %s %s%s [%s-%s]",
Expand Down
9 changes: 9 additions & 0 deletions core/src/main/resources/org/jruby/runtime/Constants.java
Expand Up @@ -39,15 +39,24 @@ public final class Constants {
public static final String RUBY_MAJOR_VERSION = "@version.ruby.major@";
public static final String RUBY_VERSION = "@version.ruby@";
public static final int RUBY_PATCHLEVEL = Integer.parseInt("@version.ruby.patchlevel@");
public static final int RUBY_REVISION = Integer.parseInt("@version.ruby.revision@");

@Deprecated
public static final String RUBY1_9_MAJOR_VERSION = "@version.ruby1_9.major@";
@Deprecated
public static final String RUBY1_9_VERSION = "@version.ruby1_9@";
@Deprecated
public static final int RUBY1_9_PATCHLEVEL = Integer.parseInt("@version.ruby1_9.patchlevel@");
@Deprecated
public static final int RUBY1_9_REVISION = Integer.parseInt("@version.ruby1_9.revision@");

@Deprecated
public static final String RUBY2_0_MAJOR_VERSION = "@version.ruby2_0.major@";
@Deprecated
public static final String RUBY2_0_VERSION = "@version.ruby2_0@";
@Deprecated
public static final int RUBY2_0_PATCHLEVEL = Integer.parseInt("@version.ruby2_0.patchlevel@");
@Deprecated
public static final int RUBY2_0_REVISION = Integer.parseInt("@version.ruby2_0.revision@");

public static final String COMPILE_DATE = "@build.date@";
Expand Down
9 changes: 0 additions & 9 deletions core/src/main/ruby/jruby/kernel/jruby/generator.rb
Expand Up @@ -258,15 +258,6 @@ def each(&block)
end
end

IS_RUBY_20 = RUBY_VERSION =~ /^2\.0/
IS_RUBY_19 = RUBY_VERSION =~ /^1\.9/ || IS_RUBY_20

if IS_RUBY_19
Enumerator = ::Enumerator
else
Enumerator = Enumerable::Enumerator
end

module Iterators
module ClassMethods
def indexed_iter(method, &block)
Expand Down
20 changes: 0 additions & 20 deletions core/src/main/ruby/jruby/kernel19.rb

This file was deleted.

45 changes: 0 additions & 45 deletions core/src/main/ruby/jruby/kernel19/enumerable.rb

This file was deleted.

11 changes: 0 additions & 11 deletions core/src/main/ruby/jruby/kernel20.rb

This file was deleted.

22 changes: 22 additions & 0 deletions core/src/main/ruby/jruby/kernel21.rb
@@ -0,0 +1,22 @@
# This is the Ruby 1.9-specific kernel file.

# Thread features are always available in 1.9.
require 'thread.jar'

# These are loads so they don't pollute LOADED_FEATURES
load 'jruby/kernel21/thread.rb'
load 'jruby/kernel21/kernel.rb'
load 'jruby/kernel21/proc.rb'
load 'jruby/kernel21/process.rb'
load 'jruby/kernel21/jruby/process_util.rb'
load 'jruby/kernel21/jruby/type.rb'
load 'jruby/kernel21/enumerator.rb'
load 'jruby/kernel21/enumerable.rb'
load 'jruby/kernel21/io.rb'
load 'jruby/kernel21/time.rb'
load 'jruby/kernel21/gc.rb'
load 'jruby/kernel21/encoding/converter.rb'
load 'jruby/kernel21/range.rb'
load 'jruby/kernel21/load_error.rb'

load 'jruby/kernel21/rubygems.rb' unless JRuby::CONFIG.rubygems_disabled?
@@ -1,3 +1,49 @@
module Enumerable
def slice_before(filter = (no_filter = true; nil), &block)
if no_filter && !block
raise ArgumentError.new("wrong number of arguments (0 for 1)")
end

if block
if no_filter
state = nil
else
initial_state = filter.dup
state = initial_state
end
else
state = nil
end

Enumerator.new do |yielder|
ary = nil
self.each do |elt|
if block
if no_filter
state = block.call elt
else
state = block.call elt, initial_state
end
else
state = (filter === elt)
end

if ary
if state
yielder.yield ary
ary = [elt]
else
ary << elt
end
else
ary = [elt]
end
end
yielder.yield ary unless ary.nil?
end
end
end

module Enumerable
def lazy
klass = Enumerator::Lazy::LAZY_WITH_NO_BLOCK # Note: class_variable_get is private in 1.8
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 6d5ddac

Please sign in to comment.