Commit Graph

173 Commits

Author SHA1 Message Date
ThePhD
7f40c4edb6 Clang errors because 2 phase lookup is stupid between compilers. 2016-03-13 08:41:29 -04:00
ThePhD
c42c1bafe5 Documentation fixes, new tests, unique/shared_ptr support.
Closes #32
2016-03-13 08:30:14 -04:00
ThePhD
d8bc6c8612 Unfortunately have to use tag dispatched types because Clang's a piece of shit. 2016-03-11 18:41:44 -05:00
ThePhD
338278edf7 The docs are here. 2016-03-11 17:47:15 -05:00
ThePhD
1a9c7484b1 Fix up the API; prepare for release. 2016-03-11 11:34:44 -05:00
ThePhD
5d722af1b0 Because bwuh. 2016-03-05 02:42:19 -05:00
ThePhD
19578538e7 Inheritance 2016-03-05 01:43:45 -05:00
ThePhD
923c774d5e ability for functions that throw not bound by sol to catch and return lua errors that can be used by a handler function (for protected function). 2016-03-02 20:45:52 -05:00
ThePhD
d42efd7fdf Proper trampolines to allow luajit to play nice with all the other kids in sol. 2016-02-27 07:56:28 -05:00
ThePhD
e57ac87868 Unused parameters and all that jazz.... 2016-02-27 02:59:47 -05:00
ThePhD
251e350539 coroutines \o/ 2016-02-27 02:43:53 -05:00
ThePhD
7402b1bc95 Clearer names for some of the exposed classes. 2016-02-25 11:07:39 -05:00
ThePhD
9c21d11b8c Proper defaults for bootstrap.py
Checks in g++ to make sure things compile
clang++ is a major asshole...
2016-02-24 13:59:17 -05:00
ThePhD
3d7a93ae1c Put detail classes not part of the interface into deeper namespaces to clear up the to level. 2016-02-23 23:39:46 -05:00
ThePhD
019c7b037b Huge improvements to the library and fixes to compile in g++.
usertype now respects factory functions and does not make default constructors/destructors unless the compiler says its okay
new and __gc functions can be overridden for usertypes to provide handle-like creation and deletion functions
Overloading match fixes
RAII improvements for all usertypes
Added tests to make sure these features stay
2016-02-21 19:26:58 -05:00
ThePhD
b2b73db5cb overloading searching improvements and general refactoring for cleaner implementation. 2016-02-18 22:17:52 -05:00
ThePhD
0ee92c0142 This is hard.... 2016-02-16 21:22:07 -05:00
ThePhD
1293213775 Several improvements to tunnneling for the library, with included tests
Some stack size tests are also included to prevent stack overflow as well.
2016-02-13 20:14:31 -05:00
ThePhD
228609ee17 Addresses derp from refactoring and #12 2016-02-12 12:47:05 -05:00
ThePhD
a71c9737d4 Fixed usertype checking for overloading resolution (and for userdata in general) 2016-02-11 02:28:38 -05:00
ThePhD
2788abb34e Overloading now works and there are tests to back it up. The codebase now relies on some C++14 features explicitly. 2016-02-10 11:36:00 -05:00
ThePhD
9372b54b02 Preparing for overload support
Preparing to benchmarking of several different lua frameworks
2016-02-09 03:38:11 -05:00
ThePhD
5034bd7980 Benchmarking will be done in a separate repository, alongside other frameworks. 2016-02-04 20:16:53 -05:00
ThePhD
b66c7f015a Significant change to how userdata is stored to make access consistent across values/references/pointers. 2016-02-01 11:56:44 -05:00
ThePhD
1d93f560f2 more luajit compatibility fixes - works with Lua 5.1, 5.2, 5.3
additional tests to make sure pass-by-value and copy semantics work as intended
new proxy_base class to reduce code duplication
update function / protected_function usage (to solve starwing's issue while keeping code as clean as possible)
2016-02-01 03:27:06 -05:00
ThePhD
27f09fbb35 variadic set - introduction of state_view type to allow for all of the benefits of state without destructing lua instance. 2016-01-30 04:21:33 -05:00
ThePhD
f389c7fe36 True luajit compatibility 2016-01-27 01:07:16 -05:00
ThePhD
31e7857870 Merge remote-tracking branch 'root/develop' into develop
# Conflicts:
#	examples/usertype.cpp
#	sol.hpp
#	sol/debug.hpp
#	sol/default_construct.hpp
#	sol/demangle.hpp
#	sol/deprecate.hpp
#	sol/error.hpp
#	sol/function.hpp
#	sol/function_types.hpp
#	sol/object.hpp
#	sol/proxy.hpp
#	sol/reference.hpp
#	sol/resolve.hpp
#	sol/stack.hpp
#	sol/state.hpp
#	sol/table.hpp
#	sol/traits.hpp
#	sol/tuple.hpp
#	sol/types.hpp
#	sol/usertype.hpp
#	sol/usertype_traits.hpp
2016-01-24 12:16:38 -05:00
ThePhD
4b545aa6a2 Fix tuple returns (they don't need to be explicitly expanded in many cases). 2015-10-25 07:17:48 -04:00
ThePhD
ad039c8cc2 Allow for usage of function error handlers with lua
TODO: make this the default mode, with a short-cutting mode (sol::no_fail_function?)
2015-10-22 11:20:32 -04:00
ThePhD
93d532094e object is now more flexible while still supporting the same semantics
indentation an spacing fixes for everything
2015-10-20 21:38:28 -04:00
ThePhD
895030c69e Remove whorish return_forward. 2015-09-07 10:43:39 -04:00
ThePhD
dbeb8b5fcb tests for the new decaying functionality
need to test with clang++/g++ to see if it still works
2015-07-22 02:54:43 -04:00
Rapptz
38d03eef6e Update copyright year. 2015-07-21 19:51:17 -04:00
ThePhD
0460b33d6c properly use decltype and throw out the get_return "type trait". It wasn't very useful anyhow. 2015-07-21 19:34:48 -04:00
ThePhD
946d01d228 Always reuse functions, avoid duplicate code... 2015-07-20 20:28:10 -04:00
ThePhD
219d10b0b4 Thanks to LUA_MULTRET, we can have normal function call syntax with sol::function that doesn't require the user to pass the arguments in directly with .call<Return1, Return2, Return3>( ... )
function result is meant to be transient, and therefore should not be regularly storeable by the user... but there is no way to make a "and you can't have anything but a temporary to this" type, as far as I can tell.
2015-07-19 10:26:11 -04:00
ThePhD
9a0dda1f3d Fix VC++ warning 2015-07-09 18:18:34 -04:00
ThePhD
069a209a4e Fixes for the g++/clang builds 2015-06-18 10:53:21 -04:00
ThePhD
ffcd1f557b Some derps on the compatibility arguments
checkargs is now properly propogated through the "call" functions
tests now define SOL_CHECK_ARGUMENTS to make sure
the tests will always check arguments now as well (caught one minor implementation detail missing from that!)
2015-06-17 18:33:58 -04:00
ThePhD
8ff921a247 A messed up space. 2015-06-17 16:53:46 -04:00
ThePhD
e70a3c945e Macro activates the library's default argument checking. Useful to verify during tests and the like. 2015-05-27 02:48:07 -04:00
ThePhD
74677a9125 RIP tabs. 2015-05-27 02:28:31 -04:00
ThePhD
712afc924f Conversions from nil to nullptr and vice-versa now properly work
Fix for really bad derp in metamethod registration
2015-05-27 02:23:37 -04:00
ThePhD
184f16d7fa Updated copyright headers and added compatibility with lua 5.1.5 and luajit!
This means sol can now run on the fastest dynamic language implementation ever!
Wooo!~
2015-05-24 21:29:21 -04:00
ThePhD
bd4492b85b This mega-commit introduces Visual Studio 2015 CTP 6 support.
sol::object had a few reference leaks in the way it retrieved values: it now does it properly without leaving the stack at +1 item
sol::stack was drastically cleaned up, with the following key change:
    * sol::stack::push now returns an integer of the number of things its pushed (usually 1, but can be more) (Thanks, @PrincessNyanara!)
    * sol::stack::call now calls functions flexibly, and getting is done more reliably
    * due to the innovation of stack::call and using absolute indices, we no longer have to use reverse_call style programming to deal with lua
    * sol::reference::get_type is now const-correct
    * sol::state and sol::table now have a cleaned up `get` implementation since it is no longer held back by the ugliness of VC++'s incapability to handle templates
    * the name `sol::userdata` now belongs to a type that actually encapsualtes a void* with a pusher/getter than gets a userdata void* value (TODO: give it a template to make it static_cast to that type on get?)
    * lightuserdata_t -> light_userdata, upvalue_t -> upvalue as type names (mostly details)
    * pushers for various types were updated to return integers
2015-03-01 21:14:42 -05:00
ThePhD
8970d3cd79 Change userdata to usertype names.
We don't need to make the function names
`open_usertype` now, since `new_usertype`
makes sense.
2014-09-29 23:10:30 -04:00
Rapptz
a11faabb5c Fix implicit conversion warnings for getter. 2014-09-29 22:45:06 -04:00
ThePhD
6121da334f Proper std::ref semantics throughout the codebase's get/set.
Also a convenience type `sol::ref`, which is just an
alias to `std::reference_wrapper`, to enable easy getting with `lua.get<>`
(we can't use `lua.get<some_type>` because of necessary `Unqualified<T>` use)
2014-09-18 00:23:46 -04:00
Rapptz
da76793c30 Formatting changes. 2014-08-10 20:49:34 -04:00
ThePhD
37c3883eb6 Free functions and lambdas whos first arguments match the userdata type (unqualified)
now are usable as functions for userdata.
allows free functions and lambdas to provide useful operations, like operator+*-/
and other things which may not be implemented as class members.
2014-08-09 04:54:58 -07:00
ThePhD
e25d4b4c02 Properly handle const value returns (and constness in general).
Keeps errors when trying to bind a const variables directly,
but const returns should be forced to value-types,
since lua has no concept of `const`.
2014-08-05 00:08:41 -07:00
ThePhD
368d78d463 userdata member variables are now supported
userdata now performs lookup based on tables
userdata now has reduced number of vector tables
userdata garbage collection improved
debug.hpp - new header for debugging problems with stack, mostly for internal use
2014-07-27 12:56:24 -07:00
ThePhD
eb25bb05bb Overloaded functions now work properly when types are specified in signature
this triggered overhaul of set_function/pusher<function_t>::push(...)
both state and table reflect changes to userdata structure to make it easier to use
tests updated to account for overload resolution
some function-related traits added to make use easier -- cleaned up archaic typenames in function_types.hpp
Account for std::reference_wrapper for objects -- sol now uses copy-by-default (value-semantics) for all functors
updated tests to reflect this
2014-06-28 23:16:48 -07:00
ThePhD
d35de4a8fa Fix for Issue #35
Userdata now properly forwards arguments to constructor
get_call now properly has extra parameters to allow for forwarding items from the first call that are not popped
Added tests to cover new cases
2014-06-27 01:25:57 -07:00
PrincessNyanara
6fbae52e9f container changes reverted
perhaps one day...
2014-06-09 06:29:06 -04:00
PrincessNyanara
0aab55cea4 inline fixes
static getter/pusher
container with Unqualified
not sure how I can make containers play nice without lookup...
2014-06-09 06:29:05 -04:00
PrincessNyanara
423e44d6dc all tests compile excepted related to test_table_return_two(), which uses contiguous container std::vector but has key-value pairs inside of it
c++ semantics dictate that it's accessed by index, but the tests seem to want to indicate that it should be accessed like a hashmap (or just using basic lua table semantics)
i have no idea how to make this incompatibility work in the new system...
i will ask repo master if he knows anything
2014-06-09 06:29:03 -04:00
PrincessNyanara
6712ebe0bd metamethods for containers represented using userdata,
`#` == __len
`[key] = value` == __newindex
`key` == __index
are not working properly for some reason, will need to investigate more deeply to find out why
on bright side all tests pass including new tests added (for take/return std::function)
fixed some things forgot to change with addition of upvalue_t for clarity (see previous commit about userdata/lightuserdata vs upvalue)
2014-06-09 06:29:01 -04:00
PrincessNyanara
736d354861 distinction between "light user data" "user data" and "upvalue", as they are not the same thing
a lua upvalue can be lightuserdata, userdata, or anything else that can have its address taken (it's immediately popped of the stack and carted around with function call)
a lightuserdata can only be a pointer (void*)
a regular userdata can be anything, but is stored as void* because of "anything" semantics and C heritage of lua
upvalues deserve to use the `lua_upvalueindex(n)` macro: lightuserdata/userdata does not (must not) go through this process
2014-06-09 06:28:59 -04:00
PrincessNyanara
77901bb654 massive rework of stack
get turned into getter<T>, matches pusher<T> and uses same semantics as std::allocator and other things used throughout the codebase
-----
userdata has its traits defined outside in new file of userdata to prevent errors when trying to use those typetraits in places before userdata.hpp gets included
userdata was changed to support returning itself via pointers or references.
rework of stack changes semantics based on T&, T*, and T&& (the last one tries to create a new userdata and move in data)
solves problems maybe presented in https://github.com/Rapptz/sol/issues/25

-----
container.hpp is attempt at solving original problem before going on wild tangent with userdata, stack, and get
is going to attempt to use userdata to allow transporation of containers losslessly, perhaps without copying need
-----
found out trying to return a std::function does not work -- not sure what do exactly?
perhaps should push c closure as last thing, but right now it is tied to a key value (code comes from table.hpp and set_function)
will just have to think over how stack arranges itself and learn what to do
2014-06-09 06:28:55 -04:00
Rapptz
675d42d281 Special casing push for types where T is base of reference 2014-06-01 02:10:36 -04:00
Rapptz
6eac584c2c Allow containers that use pairs as its value_type to return tables in lua as well 2014-06-01 01:07:26 -04:00
Rapptz
4cc402dc6e Refactored sol::stack::push to use sol::stack::pusher 2014-06-01 01:03:27 -04:00
Rapptz
5c8f661447 Allow functions that return C++ sequential containers to return tables on the lua side 2014-05-31 20:02:54 -04:00
ThePhD
42978a9ed4 Fixed segfault on GCC. It was picking the wrong overload:
by forward-declaring the std::function overload in `stack`, it is able to find the right function to use.
All tests are passing
the ninja file has been tweaked to make it easier to invoke a g++ build on windows
2014-05-31 14:29:14 -04:00
ThePhD
0315a43b1b Userdata-classes are now the assumed type for any unmatching T which are not derived from sol::reference or not one of the basic types
tests added to confirm userdata can be passed into C++ function types
demangle is now named lua_demangle, and the core demangle without any replacements (to fit lua) is just named demangle
Formattings fixes everywhere
2014-05-30 19:58:47 -04:00
ThePhD
854d735410 Additional get_call argument that defaults index to 1 (first argument of stack).
tuple_types had overlapping purpose: we should split it up soon
2014-05-30 18:21:19 -04:00
Rapptz
2376dc437b Stylistic changes to code 2014-05-29 02:57:11 -04:00
ThePhD
065215864b libstdc++ is literally the dumbest thing in the world and does not properly remove const from types with references
Must remove_reference<T> before remove_cv<T>
2014-05-29 02:38:02 -04:00
Rapptz
f9b6cf1595 Add a newline to every sol file missing one 2014-05-29 01:47:27 -04:00
Rapptz
54f030873f Remove reference when creating new reference types on the stack 2014-05-29 01:26:46 -04:00
Rapptz
932e29a841 Renamed sol_error to error 2014-05-21 22:24:15 -04:00
ThePhD
f17d30592c Fixing some basic bugs MSVC didn't catch 2014-05-09 19:32:31 -04:00
ThePhD
ff7326ed96 We now have the ability to get a userdata that has been created C++ style out of lua
Using `auto` and `decltype` in more places that MSVC can handle it -- using type traits in other places to avoid VC++'s chokes
More flexibility, woo!
2014-05-09 10:48:55 -04:00
Rapptz
63bc2b06cb Fix compiler errors, tests failing however 2014-04-27 00:53:57 -04:00
ThePhD
0088002abf Class binding now works with multiple functions
Refactoring on function_types.hpp performed to slim down some of the calls: could use more refactoring
Drastically simplified userdata's binding capabilities: constructor supports both `:` and `.` syntax (but member functions DO NOT).
All tests are passing
2014-04-26 18:24:54 -04:00
ThePhD
c0b565fa3d Renamed many parts of lua_function.hpp to make more sense.
Added pop() function to `reference`
`stack.hpp` now has many more functions to properly handle user data
`types.hpp` now has `userdata_t` and `lightuserdata_t` to faciliate `stack`'s `pop` and `push` operations
Class binding functionality built into `table` and `state`, as well as placed in `userdata` class in `userdata.hpp`
demangling detail now present for clang, gcc, and MSVC (somewhat for MSVC)
Constructor arity still needs to be handled for `userdata<T>`
tests updated and passing
2014-04-25 20:20:35 -04:00
ThePhD
b1504ad1b3 Missing inline on several functions; causes compilations when sol is included in multiple Translation Units.
`function.hpp` needed cstdint to be defined to use unit32_t properly.
2014-04-24 16:46:11 -04:00
Rapptz
02f8248d0f Fix compiler error from using sol::sol_error in get_nil 2014-01-22 12:51:09 -05:00
ThePhD
750d110a92 Fixing formatting to make sure everything's nice and pretty. 2013-12-21 22:11:20 -05:00
ThePhD
cb492e7c29 Squashing those GCC warnings. 2013-12-15 22:14:56 -05:00
ThePhD
f8cfb80a45 Fixed a bug with the return order and added tests to make sure it works.
Added the ability to get mutiple values when doing `table.get` or `state.get`.
Lua is hard. :c
2013-12-15 22:09:06 -05:00
ThePhD
e0bcf5a11e Ordering things more nicely for GCC and fixing calls to always used extra types parameters when they can for early-out decltype deduction, rather than recursive template reliance (compiles better for VC++ and resolves earlier for g++). 2013-12-15 17:09:23 -05:00
ThePhD
c8417d65de decltype with types. It seems unfair. 2013-12-15 16:56:01 -05:00
ThePhD
63536dd8d0 Why not cheat with an extra types ? Who needs type deduction when you can just pass the right types directly? 2013-12-15 16:52:01 -05:00
ThePhD
b9b32baf1a declval is in the std namespace, derp. 2013-12-15 16:46:57 -05:00
ThePhD
94405d0346 Fixing lua function, attempting another fix for rtl_pop 2013-12-15 16:45:40 -05:00
ThePhD
8ef3ceb8a0 New test cases for the order of returns. Apparently, its screwing up between both lua and C++. Have to test thoroughly. Changes currently are half-working. 2013-12-15 16:27:20 -05:00
ThePhD
6101865c1e GCC warnings can go suck a duck. 2013-12-14 23:31:23 -05:00
ThePhD
ed0b83f8b0 Several changes. I took away operator() for the proxy type, because it'd interfere with the Callable type and all. Alas, good things do die I suppose. =[
But! I left it on the `sol::function` type, because it's necessary to discard returns. The .call is still there, though, just incase you need it. <3
reverse_indices_builder is also there, to make sure we can push and pop without the lua api taking our types and breaking them for the std::tuple returns.
All is at it should be~
2013-12-14 23:25:44 -05:00
ThePhD
25f42b4bd3 A hefty slice of changes for functions on the proxy. Not necessary, but was fun to get around MSVC's ICE errors. 2013-12-14 00:15:14 -05:00
ThePhD
c6f6203ab2 We can avoid unused variable issues entirely and keep MSVC from borking out by explicitly declaring the size of the swallow declaration. This should make all compilers happy. 2013-12-13 23:26:59 -05:00
Rapptz
7cc8c93289 Move type traits to its own header and clean up code using the traits 2013-12-12 18:43:36 -05:00
Rapptz
fdf145ecd8 Minor stylistic changes to be consistent 2013-12-12 05:11:09 -05:00
ThePhD
459bbcaba0 GCC is lame. But at least it's building now. Fixed up the build.ninja and made all tests pass (exceptions weren't being thrown because of lua_pcall: use lua_call to let exceptions propogate naturally). 2013-12-11 12:42:00 -05:00
ThePhD
bcf4b9b08f Have I mentioned I hate GCC? I hate GCC. 2013-12-11 11:56:34 -05:00
ThePhD
350f430d74 Improved tests, added a build.ninja for TeamCity, and fixed formatting again to work with Rapptz's style. 2013-12-11 11:18:13 -05:00
ThePhD
dd63621453 Added some catch tests and a basic nil getter. 2013-12-11 08:32:27 -05:00
ThePhD
e53c47f7b1 Okay, so now it compiles without errors or warnings and works pretty well. This should be the last piece necessary for full working conformance. Yey~ 2013-12-09 17:01:52 -05:00