Skip to content

Commit

Permalink
Showing 340 changed files with 1,352 additions and 889 deletions.
2 changes: 1 addition & 1 deletion BUILDING.md
Original file line number Diff line number Diff line change
@@ -336,7 +336,7 @@ rake maven:dump_poms

about the ruby DSL for those poms just look in the existing pom.rb/Mavenfile files - there are plenty of examples for all kind of situations. (more documentation to come).

regular maven uses the the jruby from the installation, i.e. 9.0.0.0.dev. this also means that a regular maven run does not depend under the hood on any other jruby versions from maven central.
regular maven uses the the jruby from the installation, i.e. 9.0.0.0. this also means that a regular maven run does not depend under the hood on any other jruby versions from maven central.

at some parts there are **inline** plugins in **pom.rb** or **Mavenfile** which will work directly with regular maven where there is a special plugin running those ruby parts. see **./lib/pom.rb**.

2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
9.0.0.0-SNAPSHOT
9.0.0.0.pre1
4 changes: 2 additions & 2 deletions core/pom.xml
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@
<parent>
<groupId>org.jruby</groupId>
<artifactId>jruby-parent</artifactId>
<version>9.0.0.0-SNAPSHOT</version>
<version>9.0.0.0.pre1</version>
</parent>
<artifactId>jruby-core</artifactId>
<name>JRuby Core</name>
@@ -42,7 +42,7 @@
<parser.dir>core/src/main/java/org/jruby/parser</parser.dir>
<jruby.basedir>${basedir}/..</jruby.basedir>
<rubyspec.dir>${spec.dir}/ruby</rubyspec.dir>
<version.ruby.revision>48765</version.ruby.revision>
<version.ruby.revision>49005</version.ruby.revision>
<jruby.test.memory>3G</jruby.test.memory>
<mspec.dir>${spec.dir}/mspec</mspec.dir>
<build.date>${maven.build.timestamp}</build.date>
2 changes: 2 additions & 0 deletions core/src/main/java/org/jruby/RubyArray.java
Original file line number Diff line number Diff line change
@@ -3997,7 +3997,9 @@ private IRubyObject all_pBlockless(ThreadContext context) {
return context.runtime.getTrue();
}

@JRubyMethod(name = "any?")
public IRubyObject any_p(ThreadContext context, Block block) {
if (isEmpty()) return context.runtime.getFalse();
if (!isBuiltin("each")) return RubyEnumerable.any_pCommon(context, this, block, Arity.OPTIONAL);
if (!block.isGiven()) return any_pBlockless(context);

38 changes: 38 additions & 0 deletions core/src/main/java/org/jruby/RubyEncoding.java
Original file line number Diff line number Diff line change
@@ -50,6 +50,7 @@
import org.jruby.runtime.encoding.EncodingService;
import org.jruby.runtime.opto.OptoFactory;
import org.jruby.util.ByteList;
import org.jruby.util.CodeRangeable;
import org.jruby.util.StringSupport;
import org.jruby.util.io.EncodingUtils;
import org.jruby.util.unsafe.UnsafeHolder;
@@ -165,6 +166,43 @@ public static Encoding areCompatible(IRubyObject obj1, IRubyObject obj2) {
return null;
}

public static Encoding areCompatible(CodeRangeable obj1, CodeRangeable obj2) {
Encoding enc1 = obj1.getByteList().getEncoding();
Encoding enc2 = obj2.getByteList().getEncoding();

if (enc1 == null || enc2 == null) return null;
if (enc1 == enc2) return enc1;

if (obj2.getByteList().getRealSize() == 0) return enc1;
if (obj1.getByteList().getRealSize() == 0) {
return enc1.isAsciiCompatible() && obj2 instanceof RubyString &&
((RubyString) obj2).isAsciiOnly() ? enc1 : enc2;
}

if (!enc1.isAsciiCompatible() || !enc2.isAsciiCompatible()) return null;

int cr1 = obj1.scanForCodeRange();
if (obj2 instanceof RubyString) {
int cr2 = obj2.scanForCodeRange();
return areCompatible(enc1, cr1, enc2, cr2);
}
if (cr1 == StringSupport.CR_7BIT) return enc2;

return null;
}

public static Encoding areCompatible(Encoding enc1, Encoding enc2) {
if (enc1 == null || enc2 == null) return null;
if (enc1 == enc2) return enc1;

if (!enc1.isAsciiCompatible() || !enc2.isAsciiCompatible()) return null;

if (enc2 instanceof USASCIIEncoding) return enc1;
if (enc1 instanceof USASCIIEncoding) return enc2;

return null;
}

// last block in rb_enc_compatible
public static Encoding areCompatible(Encoding enc1, int cr1, Encoding enc2, int cr2) {
if (cr1 != cr2) {
11 changes: 0 additions & 11 deletions core/src/main/java/org/jruby/RubyEnumerable.java
Original file line number Diff line number Diff line change
@@ -968,21 +968,11 @@ public static IRubyObject each_with_index19(ThreadContext context, IRubyObject s
return block.isGiven() ? each_with_indexCommon19(context, self, block, args) : enumeratorizeWithSize(context, self, "each_with_index", args, enumSizeFn(context, self));
}

@JRubyMethod
public static IRubyObject enum_with_index(ThreadContext context, IRubyObject self, Block block) {
return block.isGiven() ? each_with_indexCommon(context, self, block) : enumeratorize(context.runtime, self, "enum_with_index");
}

@JRubyMethod
public static IRubyObject each_with_object(ThreadContext context, IRubyObject self, IRubyObject arg, Block block) {
return block.isGiven() ? each_with_objectCommon19(context, self, block, arg) : enumeratorizeWithSize(context, self, "each_with_object", new IRubyObject[] { arg }, enumSizeFn(context, self));
}

@JRubyMethod
public static IRubyObject with_object(ThreadContext context, IRubyObject self, final IRubyObject arg, final Block block) {
return block.isGiven() ? each_with_objectCommon19(context, self, block, arg) : enumeratorize(context.runtime, self, "with_object", arg);
}

@JRubyMethod(rest = true)
public static IRubyObject each_entry(ThreadContext context, final IRubyObject self, final IRubyObject[] args, final Block block) {
return block.isGiven() ? each_entryCommon(context, self, args, block) : enumeratorizeWithSize(context, self, "each_entry", args, enumSizeFn(context, self));
@@ -1461,7 +1451,6 @@ public IRubyObject call(ThreadContext ctx, IRubyObject[] largs, Block blk) {

@JRubyMethod(name = "any?")
public static IRubyObject any_p(ThreadContext context, IRubyObject self, final Block block) {
if (self instanceof RubyArray) return ((RubyArray) self).any_p(context, block);
return any_pCommon(context, self, block, block.arity());
}

17 changes: 12 additions & 5 deletions core/src/main/java/org/jruby/RubyEnumerator.java
Original file line number Diff line number Diff line change
@@ -29,8 +29,8 @@

import org.jruby.anno.JRubyMethod;
import org.jruby.anno.JRubyModule;
import org.jruby.exceptions.JumpException;
import org.jruby.exceptions.RaiseException;
import org.jruby.exceptions.Unrescuable;
import org.jruby.runtime.Arity;
import org.jruby.runtime.Block;
import org.jruby.runtime.BlockCallback;
@@ -596,6 +596,9 @@ private static class ThreadedNexter extends Nexter implements Runnable {

/** the last value we got, used for peek */
private IRubyObject lastValue;

/** Exception used for unrolling the iteration on terminate */
private static class TerminateEnumeration extends RuntimeException implements Unrescuable {}

public ThreadedNexter(Ruby runtime, IRubyObject object, String method, IRubyObject[] methodArgs) {
super(runtime, object, method, methodArgs);
@@ -708,25 +711,29 @@ public void run() {

try {
IRubyObject oldExc = runtime.getGlobalVariables().get("$!");
final TerminateEnumeration terminateEnumeration = new TerminateEnumeration();
try {
object.callMethod(context, method, methodArgs, CallBlock.newCallClosure(object, object.getMetaClass(), Arity.OPTIONAL, new BlockCallback() {
@Override
public IRubyObject call(ThreadContext context, IRubyObject[] args, Block block) {
try {
if (DEBUG) System.out.println(Thread.currentThread().getName() + ": exchanging: " + Arrays.toString(args));
if (die) throw new JumpException.BreakJump(-1, NEVER);
if (die) throw terminateEnumeration;
out.put(RubyEnumerable.packEnumValues(runtime, args));
if (die) throw new JumpException.BreakJump(-1, NEVER);
if (die) throw terminateEnumeration;
} catch (InterruptedException ie) {
if (DEBUG) System.out.println(Thread.currentThread().getName() + ": interrupted");

throw new JumpException.BreakJump(-1, NEVER);
throw terminateEnumeration;
}

return context.nil;
}
}, context));
} catch (JumpException.BreakJump bj) {
} catch (TerminateEnumeration te) {
if (te != terminateEnumeration) {
throw te;
}
// ignore, we're shutting down
} catch (RaiseException re) {
runtime.getGlobalVariables().set("$!", oldExc);
31 changes: 0 additions & 31 deletions core/src/main/java/org/jruby/RubyFile.java
Original file line number Diff line number Diff line change
@@ -410,37 +410,6 @@ public static final FileTime getBirthtimeWithNIO(String pathString) {
return null;
}

@JRubyMethod(required = 1)
public IRubyObject lchmod(ThreadContext context, IRubyObject arg) {
int mode = (int) arg.convertToInteger().getLongValue();

if (!new File(getPath()).exists()) {
throw context.runtime.newErrnoENOENTError(getPath());
}

return context.runtime.newFixnum(context.runtime.getPosix().lchmod(getPath(), mode));
}

// TODO: this method is not present in MRI!
@JRubyMethod(required = 2)
public IRubyObject lchown(ThreadContext context, IRubyObject arg1, IRubyObject arg2) {
int owner = -1;
if (!arg1.isNil()) {
owner = RubyNumeric.num2int(arg1);
}

int group = -1;
if (!arg2.isNil()) {
group = RubyNumeric.num2int(arg2);
}

if (!new File(getPath()).exists()) {
throw context.runtime.newErrnoENOENTError(getPath());
}

return context.runtime.newFixnum(context.runtime.getPosix().lchown(getPath(), owner, group));
}

@JRubyMethod
public IRubyObject lstat(ThreadContext context) {
checkClosed(context);
18 changes: 5 additions & 13 deletions core/src/main/java/org/jruby/RubyFixnum.java
Original file line number Diff line number Diff line change
@@ -342,18 +342,6 @@ public RubyString to_s(IRubyObject arg0) {
return getRuntime().newString(bl);
}

/** fix_id2name
*
*/
@JRubyMethod
public IRubyObject id2name() {
RubySymbol symbol = RubySymbol.getSymbolLong(getRuntime(), value);

if (symbol != null) return getRuntime().newString(symbol.asJavaString());

return getRuntime().getNil();
}

/** fix_to_sym
*
*/
@@ -597,7 +585,6 @@ public RubyBoolean even_p(ThreadContext context) {
return context.runtime.getFalse();
}

@JRubyMethod
public IRubyObject pred(ThreadContext context) {
return context.runtime.newFixnum(value-1);
}
@@ -1223,6 +1210,11 @@ public IRubyObject succ(ThreadContext context) {
return ((RubyFixnum) this).op_plus_one(context);
}

@JRubyMethod
public IRubyObject bit_length(ThreadContext context) {
return context.runtime.newFixnum(64 - Long.numberOfLeadingZeros(value));
}

@Override
public IRubyObject id() {
if (value <= Long.MAX_VALUE / 2 && value >= Long.MIN_VALUE / 2) {
48 changes: 36 additions & 12 deletions core/src/main/java/org/jruby/RubyHash.java
Original file line number Diff line number Diff line change
@@ -1451,10 +1451,7 @@ public void visit(IRubyObject key, IRubyObject value) {
return modified[0];
}

/** rb_hash_sort
*
*/
@JRubyMethod
@Deprecated
public IRubyObject sort(ThreadContext context, Block block) {
return to_a().sort_bang(context, block);
}
@@ -1494,14 +1491,6 @@ public void visit(IRubyObject key, IRubyObject value) {
}
}

/** rb_hash_indexes
*
*/
@JRubyMethod(name = {"indexes", "indices"}, rest = true)
public RubyArray indices(ThreadContext context, IRubyObject[] indices) {
return values_at(context, indices);
}

/** rb_hash_keys
*
*/
@@ -1889,6 +1878,41 @@ public IRubyObject rbClone(ThreadContext context) {
return clone;
}

@JRubyMethod(name = "any?")
public IRubyObject any_p(ThreadContext context, Block block) {
if (isEmpty()) return context.runtime.getFalse();

if (!block.isGiven()) return context.runtime.getTrue();

if (block.arity().getValue() > 1)
return any_p_i_fast(context, block);

return any_p_i(context, block);
}

private IRubyObject any_p_i(ThreadContext context, Block block) {
iteratorEntry();
for (RubyHashEntry entry = head.nextAdded; entry != head; entry = entry.nextAdded) {
IRubyObject newAssoc = RubyArray.newArray(context.runtime, entry.key, entry.value);
if (block.yield(context, newAssoc).isTrue())
return context.getRuntime().getTrue();
}
iteratorExit();

return context.getRuntime().getFalse();
}

private IRubyObject any_p_i_fast(ThreadContext context, Block block) {
iteratorEntry();
for (RubyHashEntry entry = head.nextAdded; entry != head; entry = entry.nextAdded) {
if (block.yieldSpecific(context, entry.key, entry.value).isTrue())
return context.getRuntime().getTrue();
}
iteratorExit();

return context.getRuntime().getFalse();
}

/**
* A lightweight dup for internal use that does not dispatch to initialize_copy nor rehash the keys. Intended for
* use in dup'ing keyword args for processing.
9 changes: 1 addition & 8 deletions core/src/main/java/org/jruby/RubyKernel.java
Original file line number Diff line number Diff line change
@@ -1038,13 +1038,6 @@ public Binding convertToBinding(IRubyObject scope) {
}
};


@JRubyMethod(module = true, visibility = PRIVATE)
public static IRubyObject callcc(ThreadContext context, IRubyObject recv, Block block) {
RubyContinuation continuation = new RubyContinuation(context.runtime);
return continuation.enter(context, continuation, block);
}

public static IRubyObject caller(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block) {
return caller20(context, recv, args, block);
}
@@ -1627,7 +1620,7 @@ public static IRubyObject exec(ThreadContext context, IRubyObject recv, IRubyObj
/* Actual exec definition which calls this internal version is specified
* in /core/src/main/ruby/jruby/kernel/kernel.rb.
*/
@JRubyMethod(required = 4, module = true, visibility = PRIVATE)
@JRubyMethod(required = 4, visibility = PRIVATE)
public static IRubyObject _exec_internal(ThreadContext context, IRubyObject recv, IRubyObject[] args) {
Ruby runtime = context.runtime;

5 changes: 3 additions & 2 deletions core/src/main/java/org/jruby/RubyMarshal.java
Original file line number Diff line number Diff line change
@@ -44,6 +44,7 @@
import org.jruby.runtime.Block;
import org.jruby.runtime.Constants;
import org.jruby.runtime.ThreadContext;
import org.jruby.runtime.Visibility;
import org.jruby.runtime.builtin.IRubyObject;
import org.jruby.runtime.marshal.MarshalStream;
import org.jruby.runtime.marshal.UnmarshalStream;
@@ -71,7 +72,7 @@ public static RubyModule createMarshalModule(Ruby runtime) {
return module;
}

@JRubyMethod(required = 1, optional = 2, module = true)
@JRubyMethod(required = 1, optional = 2, module = true, visibility = Visibility.PRIVATE)
public static IRubyObject dump(IRubyObject recv, IRubyObject[] args, Block unusedBlock) {
Ruby runtime = recv.getRuntime();
IRubyObject objectToDump = args[0];
@@ -119,7 +120,7 @@ private static void setBinmodeIfPossible(ThreadContext context, IRubyObject io)
if (io.respondsTo("binmode")) io.callMethod(context, "binmode");
}

@JRubyMethod(name = {"load", "restore"}, required = 1, optional = 1, module = true)
@JRubyMethod(name = {"load", "restore"}, required = 1, optional = 1, module = true, visibility = Visibility.PRIVATE)
public static IRubyObject load(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block unusedBlock) {
Ruby runtime = context.runtime;
IRubyObject in = args[0];
9 changes: 9 additions & 0 deletions core/src/main/java/org/jruby/RubyMethod.java
Original file line number Diff line number Diff line change
@@ -34,6 +34,7 @@
import org.jruby.ext.jruby.JRubyLibrary;
import org.jruby.anno.JRubyMethod;
import org.jruby.anno.JRubyClass;
import org.jruby.internal.runtime.methods.AliasMethod;
import org.jruby.internal.runtime.methods.DynamicMethod;
import org.jruby.internal.runtime.methods.ProcMethod;
import org.jruby.internal.runtime.methods.UndefinedMethod;
@@ -301,5 +302,13 @@ public IRubyObject super_method(ThreadContext context) {
RubyModule superClass = Helpers.findImplementerIfNecessary(receiver.getMetaClass(), implementationModule).getSuperClass();
return super_method(context, receiver, superClass);
}

@JRubyMethod
public IRubyObject original_name(ThreadContext context) {
if (method instanceof AliasMethod) {
return context.runtime.newString(((AliasMethod)method).getOldName());
}
return name(context);
}
}

Loading

0 comments on commit eb53c1b

Please sign in to comment.