1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2024-07-02 01:53:21 +00:00
Commit Graph

68 Commits

Author SHA1 Message Date
Jonathan Coates
8a203e7454
Re-license several more files under MPL-2.0
- Several files where @MCJack123 is the exclusive contributor. He has
   signed over all contributions to "any OSI-approved license". Thank
   you!

 - Various the file handle classes: Looking at these again, I don't
   think they contain any of the original code.
2023-03-28 10:28:59 +01:00
Jonathan Coates
ca279d410a
Support __name inside cc.expect
See #1355
2023-03-28 08:55:29 +01:00
Jonathan Coates
5bb2e8e8cd
Update Cobalt to 0.7
- Timeouts are now driven by an interrupt system, rather than polling.
   While we do not impose memory limits, this should close #1333.

 - Update the table library to largely match Lua 5.4:
    - Add table.move
    - Table methods (with the exception of foreach/foreachi) now use
      metamethods (closes #1088).
   There's still some remaining quirks (for instance, table.insert
   accepts values out-of-bounds), but I think that's fine.

 - Cobalt's threaded-coroutine system is gone (load now supports
   yielding), so we no longer track coroutine metrics.

 - Type errors now use __name. See #1355, though this does not apply to
   CC methods (either on the Java or CraftOS side), so is not enough to
   resolve it.

See https://github.com/SquidDev/Cobalt/compare/v0.6.0...v0.7.0 for the
full delta.
2023-03-26 19:42:55 +01:00
JackMacWindows
06af3c7240
Add more explanation on how os.epoch("ingame") works 2023-03-16 01:28:12 -04:00
Jonathan Coates
986c65f56e
Construct ILuaMachines in one go
This means creating an ILuaMachine is largely atomic - it either is
created or it fails.
2023-03-15 22:39:51 +00:00
Jonathan Coates
b9e2d0a936
Ignore metatables in textutils.serialize
Closes #1368
2023-03-15 21:53:47 +00:00
Jonathan Coates
895bc7721a
License CC:T according to the REUSE specification (#1351)
This adds SPDX license headers to all source code files, following the
REUSE[1] specification. This does not include any asset files (such as
generated JSON files, or textures). While REUSE does support doing so
with ".license" files, for now we define these licences using the
.reuse/dep5 file.

[1]: https://reuse.software/
2023-03-15 21:52:13 +00:00
Jonathan Coates
c9bb534799
Don't create a TrustManagerFactory
See the discussion in #1352 - Netty uses the system one by default,
so no sense creating our own.

Also make sure we through the HTTP error every time, not just on the
first failure. Otherwise we get cryptic connection dropped errors.
2023-03-04 11:21:06 +00:00
Jonathan Coates
1c120982a7
Distinguish between all parsers passing and failing
Given an input like f(x), which is both a valid statement and
expression, both parsers would accept the whole input. However, this was
treated the same as both parsers rejecting the input, resulting in a
crash when trying to print the error.

We now return immediately when any parser accepts the input.

Fixes #1354
2023-03-04 10:30:12 +00:00
JackMacWindows
67c462f8b0
Fix introduction dates of os.cancel[Alarm|Timer] 2023-02-27 21:57:45 -05:00
Jonathan Coates
4e909bc59e
Improve several comma related parse errors
- Suggest adding a comma on { 2 3 }
 - Suggest removing a comma on f(1, )

Closes #1341.
2023-02-17 21:07:48 +00:00
Jonathan Coates
41c83988a1
Be more rigorous in checking for invalid values in settings.load
If someone had a recursive table (created with an IIFE), then we'd throw
an error inside reserialize. We now catch this error and silently drop
the value.

I'm not thrilled by this behaviour - there's an argument we should
return false instead - but it's consistent with what we currently do.

Closes #1337.
2023-02-17 09:08:29 +00:00
Jonathan Coates
33b6f38339
Hide the internal redirect methods in multishell
Previously it was possible to access all methods of the multishell
redirect by calling term.current(). This is definitely not intended, as
it leaks all sorts of internals to the user.

Also bump illuaminate - the new version is about twice as fast on my
machine.
2023-02-12 21:26:01 +00:00
Jonathan Coates
e1ff1a8c6a
Sync changelog and whatsnew
Every time I commit code on the train I end up regretting it and telling
myself I won't do it again. I should know better by now, and yet here we
are.
2023-02-10 21:32:54 +00:00
Jonathan Coates
ab7af063c3 Remove wrapping from a couple of changelog items 2023-02-10 07:56:12 +00:00
Jonathan Coates
6a116aadb8
Bump CC:T to 1.103.1
Woops!

 - Fix the REPL not printing values, as exception.try didn't return
   values. It did originally, and then I tried to simplify it >_>

 - Change repl_exprs to run an expression and program parser in
   parallel, rather than handling the parallelism on the grammar side -
   that has a few shift/reduce conflicts which result in bad parse
   errors.
2023-02-09 21:45:20 +00:00
Jonathan Coates
9e6e0c8b88
Bump CC:T to 1.103.0 2023-02-09 21:02:09 +00:00
Jonathan Coates
5502412181
Improve display of runtime errors (#1320)
- Bump Cobalt to 0.6.0. We now track both line and column numbers of
   each bytecode instruction, allowing us to map an error to a concrete
   position.

 - `loadfile` (and similar functions) now use the full path, rather than
   the file name. Cobalt truncates this to 30 characters (rather than
   the previous 60) so this should be less noisy.

 - The shell, edit and Lua REPL now display the corresponding source
   code alongside an error.

   Note this is incredibly limited right now - it won't cope with errors
   which cross coroutine boundaries. Supporting this is on the roadmap,
   but requires some careful API design.
2023-02-09 20:53:50 +00:00
Jonathan Coates
7e54a40fa9
Add a couple of missing version annotations 2023-02-09 20:09:57 +00:00
Jonathan Coates
3075d3cea8
Fxi teh spolling of handshakder 2023-02-07 20:59:45 +00:00
Jonathan Coates
cdab8f429e
Clarify Minecraft' shift+right click behaviour
Closes #1323
2023-02-07 08:45:17 +00:00
Jonathan Coates
22cadd6730
Various improvements to our Lua parser
- Encode the DFA as a virtual machine (identical to lrgrep) rather than
   compiling it to a series of Lua functions. While this is a little
   slower and uglier, it's much more space efficient, shaving off 16Kb.

 - Minimise the DFA properly. This only shaves off a few states, but
   every little helps.

 - Run the error handling code from a non-reduced parser stack. This was
   incredibly nasty to get right (and positions are still not correctly
   handled), but it fixes several broken error messages.
2023-02-04 12:46:51 +00:00
Jonathan Coates
366052ec48
Merge pull request #1316 from LelouBil/patch-1
Fix word error in rednet documentation
2023-02-03 19:39:13 +00:00
Jonathan Coates
3224e0bf8b
Fix a few typos in the documentation
- Move modem recipes out of the usage section.
 - Add missing argument names to BinaryWriableHandle.write. Illuaminate
   really should catch this, but for now I did a grep and couldn't find
   any more instances of this.
2023-02-03 19:29:16 +00:00
Bilel MEDIMEGH
67f3d91850
Fix word error in rednet documentation
Replaced "The name this protocol exposes for the given protocol" into "The name this **computer** exposes for the given protocol"
2023-01-30 18:19:06 +01:00
Jonathan Coates
a12b405acf
Custom parse errors for Lua (#1298)
- Add several (internal) modules for lexing and parsing Lua code. These
   allow us to provide (hopefully) higher quality error messages than
   Lua's built-in messages.

 - `shell.run`, `edit` and `lua` now use this parser when fed invalid
   code. This allows us to provide better syntax errors, while not
   having any impact on the happy path.

   Note this does not affect any other mechanism for loading code 
   (`load`, `require`, `dofile`).

There's still a lot of work to do here in improving error message
quality, but hopefully this provides a good starting point.
2023-01-25 20:35:43 +00:00
Jonathan Coates
e076818b29
Bump Cobalt for even more verbose VM logging
See #1307
2023-01-25 18:47:27 +00:00
Jonathan Coates
6cd32a6368
Fix a few typos
Just ran[^1] over the codebase. Turns out we'd duplicated one of the
changelog entries entirely - I suspect due to a version merge gone
wrong!

[^1]: https://github.com/crate-ci/typos/
2023-01-24 18:47:29 +00:00
Jonathan Coates
7335a892b5
Expose test methods to required libraries
This allows us to use stub everywhere, rather than having to pass it
around as an argument.
2023-01-24 18:27:30 +00:00
Jonathan Coates
9873ccfa0d
Send the original rednet message to the current computer
We were incorrectly enquing the modem payload, not the underlying rednet
message.

Closes #1308.
2023-01-21 08:23:00 +00:00
Jonathan Coates
8cfbfe7ceb
Make errors messages in edit more obvious
See #1222.
2023-01-17 21:43:26 +00:00
Jonathan Coates
9e1de23f4a
Log internal Cobalt VM errors
See #1307
2023-01-17 20:37:16 +00:00
Jonathan Coates
86b60855d6
Enforce version bounds for the Kotlin stdlib
We were pulling in an ancient version of the jdk8 stdlib via
kotlinx.coroutines, hence the conflict in versions.
2023-01-17 20:28:31 +00:00
Emma
f43b839056
Add support for shebangs (#1273) 2023-01-14 22:12:04 +00:00
Jonathan Coates
f561572509
Bump CC:T to 1.102.2 2023-01-14 20:07:01 +00:00
Jonathan Coates
02b68b259e
Correctly track coverage for startup.lua too 2023-01-12 22:26:39 +00:00
Jonathan Coates
28a55349a9
Move coverage to the Java side
While slightly irritating (requires Cobalt magic), it's much, much
faster.
2023-01-12 21:02:33 +00:00
Jonathan Coates
2457a31728
Fix printouts crashing in item frames 2023-01-09 18:28:44 +00:00
Jonathan Coates
cdc91a8e5d
Fix stack overflow in logging code 2023-01-08 18:29:36 +00:00
Jonathan Coates
8024017f53
Bump CC:T to 1.102.1
There's still some remaining bugs (#1282), but I think worth getting the
fixes for the worst issues out first.
2023-01-08 18:21:10 +00:00
Jonathan Coates
4360458416
Attempt to reduce test flakiness
I'm really not sure why the modem one fails. I can't reproduce outside
of CI, so quite hard to debug :/.
2023-01-07 15:05:21 +00:00
Jonathan Coates
717e096b94
Include the licences of our dependencies in the credits
I feel like we should have been doing this from the beginning. Love to
uncompliant for 11 years :/.
2023-01-06 09:34:07 +00:00
Jonathan Coates
34a31abd9c
Move our internal module into the main package path
I originally put cc.import in a separate directory from the main
modules. This means that programs must extend the package path in order
to import these modules.

However, this ends up being a mixed blessing: while it makes it much
harder for users to accidentally require user code, it also means we
can't expose a public interface which wraps a private module.

Instead, cc.import now lives on the main package path, but lives under
the cc.internal namespace and is not documented anywhere. Hopefully this
should be enough of a clue that one shouldn't use it :p.
2023-01-05 21:55:08 +00:00
Jonathan Coates
e241575329
Prepare for 1.102.0
This is a stupid tradition.
2022-12-24 10:51:54 +00:00
Jonathan Coates
4fa7f50534
Time fs and peripheral operations 2022-12-15 22:12:53 +00:00
Jonathan Coates
e7fe22d4f8
Don't round trip values in executeMainThreadTask
I've been meaning to fix this for over 6 years, and just kept
forgetting.

Previously ILuaContext.executeMainThreadTask worked by running
ILuaContext.issueMainThreadTask, pulling task_complete events, and then
returning the results.

While this makes the implementation simple, it means that the task's
results were converted into Lua values (in order to queue the event) and
then back into Java ones (when the event was pulled), before eventually
being converted into Lua once more.

Not only is this inefficient, as roundtripping isn't lossless, you
couldn't return functions or rich objects from main thread functions
(see https://github.com/dan200/ComputerCraft/issues/125).

We now store the return value on the Java side and then return that when
the receiving the task_complete event - the event no longer carries the
result. Note this does not affect methods using issueMainThreadTask!
2022-12-15 20:19:28 +00:00
Jonathan Coates
2b237332ce
Update to latest Forge
This fixes the issue with DeferredRegister crashing on non-wrapped
registries.
2022-12-15 17:53:50 +00:00
Jonathan Coates
1276478deb
Use the correct import path in import.lua
Think this is worth backporting to 1.16.5. Ughr.
2022-12-14 21:29:38 +00:00
Jonathan Coates
551f6ba60c
Fix out-of-bounds read in ByteBufferChannel
Introduced in fa122a56cf by the looks of
it, so shouldn't have ever made it into a release.
2022-12-14 21:21:47 +00:00
Jonathan Coates
0787e17ebe
Use git shortlog for gathering contributors 2022-12-13 20:31:59 +00:00