Commit Graph

366 Commits

Author SHA1 Message Date
kyren 80a98ef29c Couple of changes:
- Update readme, changelog, cargo version number in preparation for release
- Remove panicking behavior on recursive callback calls, add additional error
  variant for recursive callback errors.
2017-12-04 01:47:04 -05:00
kyren 0c644e7136 more reorganization in an attempt to shrink the size of lua.rs 2017-12-04 01:04:12 -05:00
kyren a44b6b5170 Move function and thread into their own modules, auto-formatting 2017-12-04 00:57:39 -05:00
kyren 51838f3509 Include garbage collector error type, remove unnecessary setmetatable wrapper 2017-12-04 00:35:13 -05:00
kyren d76935e683 I *THINK* this might actually be it, is rlua 'm' safe now? 2017-12-04 00:15:20 -05:00
kyren d0ff10b528 I believe this is all the external API changes necessary for 'm' safety 2017-12-03 23:45:00 -05:00
kyren e80e7d4540 missing push_string calls in util 2017-12-03 23:25:03 -05:00
kyren 67e8907f19 Couple of changes in preparation for 'm' safety:
- auto formatting
- add gc control to ffi
- add gc_guard to util functions
- use gc_guard to make util error handling functions never trigger __gc
  metamethod Lua errors even without __gc metatable wrapper
- sort of a technicality, don't call luaL_requiref outside of the Lua
  constructor, as it could trigger the garbage collector when user code has had
  a chance to set __gc metamethods.  Changes the API to load the debug table.
2017-12-03 23:01:03 -05:00
kyren 0bd676aa81 more refactoring 2017-12-03 21:19:32 -05:00
kyren c95f591935 remove specific protected functions in favor of generic protect_lua_call 2017-12-03 20:29:41 -05:00
kyren 37a3145ced missed stack size fix 2017-12-03 20:15:57 -05:00
kyren a490229f31 More refactoring towards mem error safety 2017-12-03 20:10:45 -05:00
kyren 0909ca34fc auto formatting 2017-12-03 18:25:53 -05:00
kyren e41c72d642 more refactoring trying to find a workable path to 'm' error safety 2017-12-03 18:15:31 -05:00
kyren 5742e3f20a still making small structural changes
slowly trying to refactor things until using all the protected calls in
protected_ffi is workable
2017-12-02 19:16:57 -05:00
kyren f51a822738 auto-formatting 2017-12-02 18:56:14 -05:00
kyren 8a6161b16f new strategy for protected ffi calls 2017-12-02 18:37:17 -05:00
kyren b7c80ec066 make some things private 2017-12-02 17:47:00 -05:00
kyren 2b7e89e7c6 move error / panic metatable creation 2017-12-02 17:13:46 -05:00
kyren fa1703d3d1 split macros into their own file 2017-12-02 17:04:33 -05:00
kyren 8a7e03978b Experimental protected versions of all used 'm' erroring functions 2017-12-02 15:41:53 -05:00
kyren cfa2b34a7b Bump version to 0.9.7, update changelog 2017-11-08 14:07:48 -05:00
kyren cf013a6a43
Merge pull request #55 from Timidger/bugfix/setting_metatable_nil
Fixes error when setting metatable to nil
2017-11-08 00:32:38 -05:00
Timidger f9c451bd26 Add test ensuring behaviour is correct 2017-11-07 20:13:52 -08:00
Timidger 8ac27877e4 Only get gc on setmetatable if metatable isn't nil 2017-11-07 20:13:30 -08:00
kyren 33eff0e132
Merge pull request #54 from Timidger/feature/debug-unsafe-lib
Added ability to load debug lib, Fixes #52
2017-11-04 02:57:03 -04:00
Timidger a137086064 Check that we have enough room on stack for module 2017-10-29 15:26:40 -07:00
Timidger 71fdca5477 Fixed test to use Lua assert 2017-10-29 15:24:54 -07:00
Timidger 316c6976e4 Added pop after loading lua library 2017-10-29 14:54:55 -07:00
Timidger 26b7901ab3 Added test for loading unsafe debug library in Lua 2017-10-29 14:53:30 -07:00
Timidger 2658433bd1 Added ability to load debug lib, Fixes #52 2017-10-28 20:46:24 -07:00
kyren 00a3153ae0 Bump version / changelog for 0.9.6 2017-10-26 16:53:14 -04:00
kyren 892069edd6 Correctly wrap external errors so that Debug trait and Error::cause are correct 2017-10-26 16:49:16 -04:00
kyren 8592af1b16 Bump version to 0.9.5, update changelog 2017-10-25 14:55:05 -04:00
kyren deab88a851 Fix xpcall return values, make the tests a lot better. 2017-10-25 14:51:10 -04:00
kyren 773bf3e9ba Fix some clippy lints, possible edge case API incompatibility around HashMap 2017-10-24 16:15:57 -04:00
kyren 4bbeeb2b2d Update to 0.9.4, update changelog 2017-10-24 08:59:55 -04:00
kyren f634ce1101 It turns out, luaL_ref uses 1 extra internal stack space
All my check_stack calls are wrong, and this blows up very easily in situations
with recursive data structures.
2017-10-24 08:53:26 -04:00
kyren e7661a5c27 auto-formatting 2017-10-23 16:42:20 -04:00
kyren 8c30acec4e Possibly better stack behavior 2017-10-23 15:17:46 -04:00
kyren ba183b0119 Fix quadratic behavior in bind 2017-10-23 14:50:47 -04:00
kyren 4a7881f652 Whoops, messed up the version in the changelog. 2017-10-14 19:33:53 -04:00
kyren 401c06cfe6 Bump cargo version to 0.9.3, update changelog. 2017-10-14 19:27:24 -04:00
kyren 8a2cfeb00d Update readme regarding plans for panic / abort safety and other clarifications 2017-10-14 18:53:05 -04:00
kyren 4b7a3403bc Cleanups of userdata handling, particularly around callbacks
First, make sure that `add_methods` cannot trigger another userdata registry
insert, causing an unintended panic.  Second, remove `RefCell` surrounding
userdata hashmap, as this change makes it no longer needed.  Third, add a
`RefCell` around `Callback` because FnMut means that callbacks cannot recurse
into themselves, and panic appropriately when this happens.  This should
eventually be turned into an error.
2017-10-14 18:26:09 -04:00
kyren c5a4dfd7eb more reorganization, move simple type defines to types.rs module 2017-09-30 01:27:18 -04:00
kyren 8324d9e648 move userdata tests into userdata.rs 2017-09-30 01:13:58 -04:00
kyren 7a45490aca crudely move LightUserData/UserData/AnyUserData to their own module 2017-09-30 01:08:08 -04:00
kyren cf764fbabe move table tests to table.rs 2017-09-30 00:53:28 -04:00
kyren f785180a77 Merge pull request #45 from jonas-schievink/string
Extend String API
2017-09-30 00:43:19 -04:00
kyren cc502379c1 Print CallbackError in a better way
CallbackError now, instead of displaying the cause description, instead prints
"callback error: <traceback>".  Since the cause is already in the cause chain of
the error, this avoids repeatedly printing the cause of callback errors along
the chain, and also actually prints the callback when using Display on each
error in the chain.
2017-09-26 11:36:50 -04:00
kyren ef538d8757 Update rlua to 0.9.2, add SOME kind of changelog. 2017-09-24 19:32:26 -04:00
kyren 61dc2823a6 Merge pull request #47 from jonas-schievink/base--
Don't load the base library into the "base" global
2017-09-16 21:09:33 -04:00
Jonas Schievink a7a080b50a Don't load the base library into the "base" global
The stock Lua interpreter doesn't do this either. AFAIK the "base" library is supposed to be loaded into "_G" only as it contains functions like `assert` and `error`.
2017-09-17 00:07:19 +02:00
kyren 4b035af0e8 Merge pull request #44 from jonas-schievink/linkfix
Fix links in `Variadic` docs
2017-09-15 19:43:12 -04:00
Jonas Schievink a5b6d8fc85 Add `String::as_bytes_with_nul`
This cannot be accomplished without using unsafe code, which justifies this addition in my opinion.

Also changes "null" to "nul" to be in sync with `std::ffi` docs. Naming is derived from `CStr::to_bytes_with_nul`, using `as_*` instead of `to_*` since this isn't doing any computation.
2017-09-15 23:33:28 +02:00
Jonas Schievink 0e4414fc0b Impl `AsRef<[u8]>` and generic `PartialEq` for `String`
Tests are also moved to the new string.rs file to ensure related functionality is in one place.
2017-09-15 23:10:53 +02:00
Jonas Schievink 823dd39e5d Move string and table wrappers into own files 2017-09-15 22:03:14 +02:00
Jonas Schievink 14d8b4a0a2 Fix links in `Variadic` docs 2017-09-15 20:56:46 +02:00
kyren 121bac8394 Merge pull request #43 from jonas-schievink/dire-dire-docs
More documentation work
2017-09-14 23:27:57 -04:00
Jonas Schievink 22cbed0240 More documentation work 2017-09-14 22:59:59 +02:00
kyren d862c0f08e Add methods to get/set metatables on Table
Also make Table::raw_get actually use raw get function instead of lua_gettable!
2017-09-10 19:14:51 -04:00
kyren 13dc68c36d Rename 'lua lifetimes to actually be 'lua 2017-09-09 21:29:22 -04:00
kyren ec088300f2 Specify `gcc` crate dependency with minimum bound on version with `Build` 2017-09-09 21:04:57 -04:00
kyren 94ee0aaf16 Merge pull request #42 from thelearnerofcode/master
Switched gcc::Config to gcc:Build in build.rs.
2017-09-09 20:58:07 -04:00
thelearnerofcode 21bb04da36 Switched gcc::Config to gcc:Build in build.rs. 2017-09-09 15:03:35 -04:00
kyren 5bf228fbd0 Fixup grammar error in doc comments. 2017-08-03 17:07:54 -04:00
kyren 50436d3463 autoformatting 2017-08-03 02:03:28 -04:00
kyren 1b082b17bc Don't refer to renamed prelude versions of types, refer to their normal name 2017-08-02 18:21:47 -04:00
kyren 1efef92570 I guess I need to bump the cargo version even to change the badge. 2017-08-02 17:43:44 -04:00
kyren fffeb9701b Badge has wrong url, I guess it doesn't expect the github portion 2017-08-02 17:42:58 -04:00
kyren b42d613c5b Update Cargo.toml for 0.9, add travis-ci badge 2017-08-02 17:37:29 -04:00
kyren d5552c494a Typo fix 2017-08-02 17:26:25 -04:00
kyren 93e8d7bc5c Merge pull request #37 from jonas-schievink/patch-1
Deny warnings on Travis
2017-08-02 17:17:06 -04:00
Jonas Schievink bc3add1a8f Deny warnings on Travis
Always treating warnings as errors makes development annoying ("ugh I don't want to fix this right now"), but ignoring them quickly leaves them unfixed and shines a bad light on the project when other people want build it ("hmm, this crate's a little to... yellow for my taste"). I've found that this is pretty much a perfect middle ground (even though rlua doesn't require CI to pass before merging PRs).
2017-08-02 23:13:02 +02:00
kyren ffc9b032e7 Riiight, doctests don't even *show* warnings by default, this flag is important. 2017-08-02 17:12:34 -04:00
kyren cac4141871 Update README for 0.9 2017-08-02 17:04:44 -04:00
kyren b03397137b deny(warnings) on doctests I don't think is necessary anymore? 2017-08-02 16:37:55 -04:00
kyren 7c32ace204 Whoops, was testing removing that and placed it back in the wrong place 2017-08-02 16:37:30 -04:00
kyren 2553623b65 Provide custom allocators that ensure that OOM results in an abort
(closes unsafety hole)
2017-08-02 16:33:48 -04:00
kyren 16f57d18e5 Merge pull request #34 from jonas-schievink/better-error
[WIP] Enhanced errors
2017-08-02 16:00:08 -04:00
kyren c3c7d8c093 setmetatable should return the table 2017-08-02 15:56:16 -04:00
Jonas Schievink dd1d335cee Handle LUA_ERRERR 2017-08-02 21:41:35 +02:00
kyren 9c34d4b99f Fix soundness problems with rlua
setmetatable now wraps a __gc method in a cclosure that aborts on error, also
'debug' library is no longer provided.  We could provide just the subset of the
debug library that is sound, though.
2017-08-02 14:36:54 -04:00
kyren 820c38e806 Rename Active / Dead to better reflect their behavior 2017-08-02 13:05:26 -04:00
kyren b458f91aac Merge pull request #35 from jonas-schievink/repl
Use rustyline for the REPL
2017-08-02 11:21:08 -04:00
kyren f9f3d05804 Fix argument bugs with pcall / xpcall, add tests for it 2017-08-02 10:42:18 -04:00
Jonas Schievink 95698735a2 Fix multiline inputs 2017-08-02 14:36:10 +02:00
Jonas Schievink 3f20319a84 Use rustyline for the REPL
This makes the REPL more usable as you can now edit lines and recall
previously executed statements.
2017-08-02 14:32:45 +02:00
Jonas Schievink 70f05ac068 Remove ErrorError 2017-08-02 14:01:00 +02:00
Jonas Schievink a43bfd8f63 Remove expected field from FromLuaConversionError 2017-08-02 13:56:28 +02:00
kyren f6cefca916 Remove stray 'for<'a>' of unused 'a lifetime 2017-08-01 18:35:09 -04:00
Jonas Schievink a1626399c4 Fix compilation 2017-08-01 23:43:51 +02:00
Jonas Schievink cb61d53ba5 Fix error message and shorten code 2017-08-01 23:42:42 +02:00
Jonas Schievink ed6e7ed5e7 Don't dispose whole traceback when it's not utf-8 2017-08-01 23:38:12 +02:00
Jonas Schievink 38a13c906e Remove "lua" prefix from error messages
Since this is `rlua::Error`, it should be clear that it refers to
Lua-related errors. Downstream crates want to define their own error
enums, which can add a prefix like "lua error:" to disambiguate.
2017-08-01 23:23:31 +02:00
Jonas Schievink bf76e41487 Merge IncompleteStatement into SyntaxError
Both are a form of syntax error, this reflects that better. No
functionality is lost, incomplete inputs are moved to a bool field of
SyntaxError.
2017-08-01 23:23:31 +02:00
Jonas Schievink ed0565c176 Fix handling of `CallbackError`
Previously, the traceback would be printed, but not the actual error.

I've removed traceback printing completely, not sure if that's a good
idea. A `Display` impl that outputs multiple lines feels weird.
2017-08-01 23:23:31 +02:00
Jonas Schievink 7e250dacce Enhance error messages 2017-08-01 23:23:31 +02:00
kyren 64ac8b4679 Merge pull request #32 from chucklefish/tuples
Major API changes before 0.9
2017-08-01 14:52:46 -04:00