Skip to content

Commit

Permalink
Update Cobalt to 0.9.0
Browse files Browse the repository at this point in the history
 - Debug hooks are now correctly called for every function.
 - Fix several minor inconsistencies with debug.getinfo.
 - Fix Lua tables being sized incorrectly when created from varargs.
  • Loading branch information
SquidDev committed Jan 27, 2024
1 parent d38b1d0 commit cb25f6c
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 73 deletions.
2 changes: 1 addition & 1 deletion doc/reference/breaking_changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ of the mod should run fine on later versions.
However, some changes to the underlying game, or CC: Tweaked's own internals may break some programs. This page serves
as documentation for breaking changes and "gotchas" one should look out for between versions.

## CC: Tweaked 1.109.0 to 1.109.2 {#cct-1.109}
## CC: Tweaked 1.109.0 to 1.109.3 {#cct-1.109}

- Update to Lua 5.2:
- Support for Lua 5.0's pseudo-argument `arg` has been removed. You should always use `...` for varargs.
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ slf4j = "2.0.1"
asm = "9.6"
autoService = "1.1.1"
checkerFramework = "3.42.0"
cobalt = "0.8.2"
cobalt = "0.9.0"
commonsCli = "1.6.0"
jetbrainsAnnotations = "24.1.0"
jsr305 = "3.0.2"
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,7 @@ public void close() {
private LuaTable wrapLuaObject(Object object) {
var table = new LuaTable();
var found = luaMethods.forEachMethod(object, (target, name, method, info) ->
table.rawset(name, info != null && info.nonYielding()
? new BasicFunction(this, method, target, context, name)
: new ResultInterpreterFunction(this, method, target, context, name)));
table.rawset(name, new ResultInterpreterFunction(this, method, target, context, name)));

return found ? table : null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ protected Varargs invoke(LuaState state, DebugFrame debugFrame, Varargs args) th
}

@Override
protected Varargs resumeThis(LuaState state, Container container, Varargs args) throws LuaError, UnwindThrowable {
public Varargs resume(LuaState state, Container container, Varargs args) throws LuaError, UnwindThrowable {
MethodResult results;
var arguments = CobaltLuaMachine.toObjects(args);
try {
Expand All @@ -98,6 +98,6 @@ public static LuaError wrap(LuaException exception, int adjust) {
if (!exception.hasLevel() && adjust == 0) return new LuaError(exception.getMessage());

var level = exception.getLevel();
return new LuaError(exception.getMessage(), level <= 0 ? level : level + adjust + 1);
return new LuaError(exception.getMessage(), level <= 0 ? level : level + adjust);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ public void testExtra() {
public void testPeripheralThrow() {
ComputerBootstrap.run(
"local throw = peripheral.wrap('top')\n" +
"local _, err = pcall(throw.thisThread) assert(err == 'pcall: !', err)\n" +
"local _, err = pcall(throw.mainThread) assert(err == 'pcall: !', err)",
"local _, err = pcall(function() throw.thisThread() end) assert(err == '/test.lua:2: !', (\"thisThread: %q\"):format(err))\n" +
"local _, err = pcall(function() throw.mainThread() end) assert(err == '/test.lua:3: !', (\"mainThread: %q\"):format(err))\n",
x -> x.getEnvironment().setPeripheral(ComputerSide.TOP, new PeripheralThrow()),
50
);
Expand Down

0 comments on commit cb25f6c

Please sign in to comment.