Commit graph

326 commits

Author SHA1 Message Date
Jonas Schievink 16ae4720d6 Rename LuaString::get to to_str
This is what similar types in libstd do (`CStr::to_str`,
`OsStr::to_str`, `Path::to_str`).
2017-06-18 14:48:45 +02:00
Jonas Schievink a47a6e32ef Rename LuaTable::has to contains_key
This is what all Rust maps use
2017-06-18 14:39:18 +02:00
Jonas Schievink ed210e88b5 Rename LuaTable::(raw_)length to (raw_)len
All Rust containers use `len` for this. Even in the Lua API, this is
called `lua_len` and `lua_rawlen`.
2017-06-18 14:36:30 +02:00
Jonas Schievink de0f3dc3c0 Rename Lua::load to Lua::exec
When talking about "loading" Lua code, it usually means compiling a
chunk of code into a runnable Lua function, but without actually
running it. This makes that clear.
2017-06-18 14:31:38 +02:00
kyren ba9f7a2ee7 Add mostly untested missing metamethods, improve documentation about them 2017-06-18 00:28:55 -04:00
kyren 56a30fba2e Slightly more palatable coroutine API 2017-06-17 23:50:40 -04:00
kyren 4d34ccdba1 Merge pull request #9 from jonas-schievink/docs
Documentation
2017-06-17 23:28:13 -04:00
kyren edc5fc8ce3 ACTUALLY check the status of lua threads before calling resume 2017-06-17 22:40:09 -04:00
Jonas Schievink 0e14d787b7 Documentation 2017-06-18 03:31:20 +02:00
kyren 32c83d77b7 small warning / clippy fixes, doc comments 2017-06-15 16:27:39 -04:00
kyren 0022057058 rustfmt changes 2017-06-15 10:26:39 -04:00
kyren 8440298e71 Go ahead and release 0.5.0
partially for the selfish reason that my submodule setup does not deal well with
ureleased versions of cargo libs where the version number ends with -pre
2017-06-11 01:33:08 -04:00
kyren 5c8aa19b8d Two major API changes:
Allow load to return values, allows reimplementing require() like functions
properly.

Make globals table explicit in Lua, remove Lua::get / Lua::set in favor of
Lua::globals.  Allows obeying globals metatable, using other Table functions on
the globals table.

Also added "has" method as shorthand for checking whether a table entry is not
nil.
2017-06-11 01:12:25 -04:00
kyren 8203414b76 Use LUA_RIDX_MAINTHREAD instead of weird bespoke method 2017-06-05 05:03:18 -04:00
kyren 1c0b1014ee Improve performance of create_table / create_array_table 2017-06-05 01:46:45 -04:00
kyren 9aed99e3e3 atpanic function was not a good idea, it's not sound
It crosses the C api boundary, the only proper way to panic would be to actually
error guard everywhere, aborting is fine.
2017-06-05 01:05:41 -04:00
kyren b3218137e1 Somewhat smarter strategy for error_guard calls, less ungodly slow.
Also add raw_length table function
2017-06-05 00:41:48 -04:00
kyren 47d4ea62ff Handle unprotected lua errors SOMEWHAT more elegantly
There should be drastically less ways to cause unprotected lua errors now, as
the LuaTable functions which were trivial to cause unprotected errors are now
protected. Unfortunately, they are protected in a pretty slow, terrible way
right now, but it at least works.

Also, set the atpanic function in lua to call a proper rust panic instead.
2017-06-05 00:03:39 -04:00
kyren e265633fb3 Callback versions of table functions 2017-05-26 23:49:12 -04:00
kyren 53b001cfce doc update again to test submodules 2017-05-25 12:12:12 -04:00
kyren c88762e90f Small doc update (secretly this is just to test submodules) 2017-05-25 12:01:12 -04:00
kyren acd0611692 Make Lua::to / Lua::from operate the correct way around
I know that Lua::to uses FromLua and Lua::from uses ToLua, but it only
makes sense that Lua::from(42) would return the LuaValue for 42, and
that Lua::to::<i64>(v) would convert the given lua value TO an integer.
The way it was just incredibly backwards.
2017-05-25 00:47:48 -04:00
kyren 87a395206d Correct checking of LuaRef origin, support lightuserdata
All lua types should now be at least somewhat usable from rust, if
incompletely so.  Any lua value should be readable in Rust as a
LuaValue, pop_value should never panic except in internal logic errors.
2017-05-25 00:43:35 -04:00
kyren 0111625d17 Basic coroutine support, currently very slightly broken
There is no longer any protection in passing LuaValue between
independent states, it is being re-added
2017-05-24 23:29:57 -04:00
kyren edb86bdeb7 Doc updates, remove unused functions 2017-05-21 22:32:16 -04:00
kyren 065c69894a Initial import 2017-05-21 19:50:59 -04:00