Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: bfc096921931
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: ec084c67a1a7
Choose a head ref
  • 4 commits
  • 5 files changed
  • 1 contributor

Commits on Nov 5, 2014

  1. New nest function for upcoming changes. string end should return actu…

    …al end char and dbeg now returns char value
    enebo committed Nov 5, 2014
    Copy the full SHA
    08c3238 View commit details

Commits on Nov 6, 2014

  1. Copy the full SHA
    b53e2b0 View commit details
  2. Copy the full SHA
    551db13 View commit details
  3. Copy the full SHA
    ec084c6 View commit details
80 changes: 40 additions & 40 deletions core/src/main/java/org/jruby/ext/digest/RubyDigest.java
Original file line number Diff line number Diff line change
@@ -243,100 +243,100 @@ private static IRubyObject throwUnimplError(IRubyObject self, String name) {

/* instance methods that should be overridden */
@JRubyMethod(name = {"update", "<<"}, required = 1)
public static IRubyObject update(ThreadContext ctx, IRubyObject self, IRubyObject arg) {
public static IRubyObject update(ThreadContext context, IRubyObject self, IRubyObject arg) {
return throwUnimplError(self, "update");
}

@JRubyMethod()
public static IRubyObject finish(ThreadContext ctx, IRubyObject self) {
public static IRubyObject finish(ThreadContext context, IRubyObject self) {
return throwUnimplError(self, "finish");
}

@JRubyMethod()
public static IRubyObject reset(ThreadContext ctx, IRubyObject self) {
public static IRubyObject reset(ThreadContext context, IRubyObject self) {
return throwUnimplError(self, "reset");
}

@JRubyMethod()
public static IRubyObject digest_length(ThreadContext ctx, IRubyObject self) {
return digest(ctx, self, null).convertToString().bytesize();
public static IRubyObject digest_length(ThreadContext context, IRubyObject self) {
return digest(context, self, null).convertToString().bytesize();
}

@JRubyMethod()
public static IRubyObject block_length(ThreadContext ctx, IRubyObject self) {
public static IRubyObject block_length(ThreadContext context, IRubyObject self) {
return throwUnimplError(self, "block_length");
}

/* instance methods that may be overridden */
@JRubyMethod(name = "==", required = 1)
public static IRubyObject op_equal(ThreadContext ctx, IRubyObject self, IRubyObject oth) {
if(oth.isNil()) return ctx.runtime.getFalse();
public static IRubyObject op_equal(ThreadContext context, IRubyObject self, IRubyObject oth) {
if(oth.isNil()) return context.runtime.getFalse();

RubyString str1, str2;
RubyModule instance = (RubyModule)ctx.runtime.getModule("Digest").getConstantAt("Instance");
RubyModule instance = (RubyModule)context.runtime.getModule("Digest").getConstantAt("Instance");
if (oth.getMetaClass().getRealClass().hasModuleInHierarchy(instance)) {
str1 = digest(ctx, self, null).convertToString();
str2 = digest(ctx, oth, null).convertToString();
str1 = digest(context, self, null).convertToString();
str2 = digest(context, oth, null).convertToString();
} else {
str1 = to_s(ctx, self).convertToString();
str1 = to_s(context, self).convertToString();
str2 = oth.convertToString();
}
boolean ret = str1.bytesize().eql(str2.bytesize()) && (str1.eql(str2));
return ret ? ctx.runtime.getTrue() : ctx.runtime.getFalse();
return ret ? context.runtime.getTrue() : context.runtime.getFalse();
}

@JRubyMethod()
public static IRubyObject inspect(ThreadContext ctx, IRubyObject self) {
return RubyString.newStringNoCopy(self.getRuntime(), ByteList.plain("#<" + self.getMetaClass().getRealClass().getName() + ": " + hexdigest(ctx, self, null) + ">"));
public static IRubyObject inspect(ThreadContext context, IRubyObject self) {
return RubyString.newStringNoCopy(self.getRuntime(), ByteList.plain("#<" + self.getMetaClass().getRealClass().getName() + ": " + hexdigest(context, self, null) + ">"));
}

/* instance methods that need not usually be overridden */
@JRubyMethod(name = "new")
public static IRubyObject newObject(ThreadContext ctx, IRubyObject self) {
return self.rbClone().callMethod(ctx, "reset");
public static IRubyObject newObject(ThreadContext context, IRubyObject self) {
return self.rbClone().callMethod(context, "reset");
}

@JRubyMethod(optional = 1)
public static IRubyObject digest(ThreadContext ctx, IRubyObject self, IRubyObject[] args) {
public static IRubyObject digest(ThreadContext context, IRubyObject self, IRubyObject[] args) {
IRubyObject value = null;
if (args != null && args.length > 0) {
self.callMethod(ctx, "reset");
self.callMethod(ctx, "update", args[0]);
value = self.callMethod(ctx, "finish");
self.callMethod(ctx, "reset");
self.callMethod(context, "reset");
self.callMethod(context, "update", args[0]);
value = self.callMethod(context, "finish");
self.callMethod(context, "reset");
} else {
IRubyObject clone = self.rbClone();
value = clone.callMethod(ctx, "finish");
clone.callMethod(ctx, "reset");
value = clone.callMethod(context, "finish");
clone.callMethod(context, "reset");
}
return value;
}

@JRubyMethod(name = "digest!")
public static IRubyObject digest_bang(ThreadContext ctx, IRubyObject self) {
IRubyObject value = self.callMethod(ctx, "finish");
self.callMethod(ctx, "reset");
public static IRubyObject digest_bang(ThreadContext context, IRubyObject self) {
IRubyObject value = self.callMethod(context, "finish");
self.callMethod(context, "reset");
return value;
}

@JRubyMethod(optional = 1)
public static IRubyObject hexdigest(ThreadContext ctx, IRubyObject self, IRubyObject[] args) {
return toHexString(ctx.runtime, digest(ctx, self, args).convertToString().getBytes());
public static IRubyObject hexdigest(ThreadContext context, IRubyObject self, IRubyObject[] args) {
return toHexString(context.runtime, digest(context, self, args).convertToString().getBytes());
}

@JRubyMethod(name = "hexdigest!")
public static IRubyObject hexdigest_bang(ThreadContext ctx, IRubyObject self) {
return toHexString(ctx.runtime, digest_bang(ctx, self).convertToString().getBytes());
public static IRubyObject hexdigest_bang(ThreadContext context, IRubyObject self) {
return toHexString(context.runtime, digest_bang(context, self).convertToString().getBytes());
}

@JRubyMethod()
public static IRubyObject to_s(ThreadContext ctx, IRubyObject self) {
return self.callMethod(ctx, "hexdigest");
public static IRubyObject to_s(ThreadContext context, IRubyObject self) {
return self.callMethod(context, "hexdigest");
}

@JRubyMethod(name = {"length", "size"})
public static IRubyObject length(ThreadContext ctx, IRubyObject self) {
return self.callMethod(ctx, "digest_length");
public static IRubyObject length(ThreadContext context, IRubyObject self) {
return self.callMethod(context, "digest_length");
}
}

@@ -354,22 +354,22 @@ public DigestClass(Ruby runtime, RubyClass type) {
}

@JRubyMethod(name = "digest", required = 1, rest = true, meta = true)
public static IRubyObject s_digest(ThreadContext ctx, IRubyObject recv, IRubyObject[] args, Block unusedBlock) {
public static IRubyObject s_digest(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block unusedBlock) {
Ruby runtime = recv.getRuntime();
if (args.length < 1) {
throw runtime.newArgumentError("no data given");
}
RubyString str = args[0].convertToString();
IRubyObject[] newArgs = new IRubyObject[args.length - 1];
System.arraycopy(args, 1, newArgs, 0, args.length - 1);
IRubyObject obj = ((RubyClass)recv).newInstance(ctx, newArgs, Block.NULL_BLOCK);
return obj.callMethod(ctx, "digest", str);
IRubyObject obj = ((RubyClass)recv).newInstance(context, newArgs, Block.NULL_BLOCK);
return obj.callMethod(context, "digest", str);
}

@JRubyMethod(name = "hexdigest", required = 1, optional = 1, meta = true)
public static IRubyObject s_hexdigest(ThreadContext ctx, IRubyObject recv, IRubyObject[] args, Block unusedBlock) {
public static IRubyObject s_hexdigest(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block unusedBlock) {
Ruby runtime = recv.getRuntime();
byte[] digest = recv.callMethod(ctx, "digest", args, Block.NULL_BLOCK).convertToString().getBytes();
byte[] digest = recv.callMethod(context, "digest", args, Block.NULL_BLOCK).convertToString().getBytes();
return RubyDigest.toHexString(runtime, digest);
}
}
4 changes: 2 additions & 2 deletions core/src/main/java/org/jruby/ext/fiber/ThreadFiber.java
Original file line number Diff line number Diff line change
@@ -98,7 +98,7 @@ private static IRubyObject exchangeWithFiber(ThreadContext context, FiberData cu

// Note: these need to be separate try/catches because of the while loop.
try {
targetFiberData.queue.push(context, val);
targetFiberData.queue.push(context, new IRubyObject[] {val});
} catch (RaiseException re) {
handleExceptionDuringExchange(context, currentFiberData, targetFiberData, re);
}
@@ -259,7 +259,7 @@ public void run() {
result = block.yieldArray(context, init, null);
}

data.prev.data.queue.push(context, result);
data.prev.data.queue.push(context, new IRubyObject[] { result });
} finally {
data.queue.shutdown();
runtime.getThreadService().disposeCurrentThread();
4 changes: 4 additions & 0 deletions core/src/main/java/org/jruby/lexer/yacc/HeredocTerm.java
Original file line number Diff line number Diff line change
@@ -64,6 +64,10 @@ public HeredocTerm(ByteList marker, int func, ByteList lastLine) {
this.flags = func;
this.lastLine = lastLine;
}

public int getNest() {
return 0;
}

public int parseString(RubyLexer lexer, LexerSource src) throws java.io.IOException {
boolean indent = (flags & RubyLexer.STR_FUNC_INDENT) != 0;
1 change: 1 addition & 0 deletions core/src/main/java/org/jruby/lexer/yacc/StrTerm.java
Original file line number Diff line number Diff line change
@@ -28,5 +28,6 @@
package org.jruby.lexer.yacc;

public abstract class StrTerm {
public abstract int getNest();
public abstract int parseString(RubyLexer lexer, LexerSource src) throws java.io.IOException;
}
12 changes: 8 additions & 4 deletions core/src/main/java/org/jruby/lexer/yacc/StringTerm.java
Original file line number Diff line number Diff line change
@@ -56,6 +56,10 @@ public StringTerm(int flags, int begin, int end) {
this.nest = 0;
}

public int getNest() {
return nest;
}

protected ByteList createByteList(RubyLexer lexer) {
return new ByteList(new byte[]{}, lexer.getEncoding());
}
@@ -75,7 +79,7 @@ private int endFound(RubyLexer lexer, LexerSource src) throws IOException {
return Tokens.tREGEXP_END;
}

lexer.setValue("\"");
lexer.setValue("" + end);
return Tokens.tSTRING_END;
}

@@ -99,7 +103,7 @@ private int parsePeekVariableName(RubyLexer lexer, LexerSource src) throws IOExc
src.unread(c3); src.unread(c2);
break;
} else if (lexer.isGlobalCharPunct(c2)) { // $_ potentially
lexer.setValue("#" + c2);
lexer.setValue("#" + (char) c2);

src.unread(c2); src.unread(c);
return Tokens.tSTRING_DVAR;
@@ -130,7 +134,7 @@ private int parsePeekVariableName(RubyLexer lexer, LexerSource src) throws IOExc
break;
}
case '{':
lexer.setValue("#" + c);
lexer.setValue("#" + (char) c);
return Tokens.tSTRING_DBEG;
default:
// We did not find significant char after # so push it back to
@@ -155,7 +159,7 @@ public int parseString(RubyLexer lexer, LexerSource src) throws IOException {
// FIXME: How much more obtuse can this be?
// Heredoc already parsed this and saved string...Do not parse..just return
if (flags == -1) {
lexer.setValue("\"");
lexer.setValue("" + end);
return Tokens.tSTRING_END;
}