Commit Graph

120 Commits

Author SHA1 Message Date
ThePhD
16c6f62fe3 Remove strerror deprecation remark 2016-02-22 02:44:27 -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
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
17c8f8e04d Mo' problems, mo' tests. 2016-02-12 12:56:32 -05:00
ThePhD
228609ee17 Addresses derp from refactoring and #12 2016-02-12 12:47:05 -05:00
ThePhD
427194bc92 Improved functions example and adjusted all errors for g++ conformance with -Wall -Werror 2016-02-10 12:12:09 -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
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
9ff968a09b Heavily improved benchmark and first set of optimizations to sol/table.hpp, providing much lower access times for calling a function. 2016-01-08 16:16:06 -05:00
ThePhD
3e17b24065 static members are hard to deal with in regular memory...
Also, make sure tuple returns don't get shafted by the tuple_types machinery!
2015-10-25 07:44:17 -04:00
ThePhD
e84cf66683 decay to std::string instead of char*, as its both safer (protects against early stack pops) and is handled better by g++'s new std::string conversion constructors
Make sure we're only using C++11 features (no decltype(auto))
2015-10-25 06:48:19 -04:00
ThePhD
34af96214b tests for the lua call error handling functions... 2015-10-23 02:54:26 -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
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
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
e816d07121 Standard-compliant function signature deduction (cannot use set_function<Args...> format as that creates an ambiguity)
state now has for_each (runs on global table like all other functions)
added for_each tests, per @Rapptz request
2015-05-15 22:26:18 -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
0373dd4eb2 Change userdata to usertype names.
We don't need to make the function names
`open_usertype` now, since `new_usertype`
makes sense.
2014-09-19 08:22:21 -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
0a2050769c Remove local from variable in test. 2014-09-07 01:06:08 -04:00
Rapptz
e015dace71 Add regression tests for issue #48. 2014-09-05 16:06:48 -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
63e66a40c2 Fix clang builds due to being unable to use shortcut-syntax for overloaded. You must specify the whole signature (how droll). 2014-08-05 09:07:29 -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
30c1f8c1b8 Tabs to spaces 2014-07-01 19:18:03 -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
b41f92adc9 updated tests
fixed small error in state with new system
all tests passing GCC 4.9 std=c++11
2014-06-27 21:34:18 -07:00
ThePhD
5930818891 Fixed tests spacing 2014-06-27 01:40:51 -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
Rapptz
7976b280e9 Add tests for issue #25 2014-06-09 09:18:29 -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
Rapptz
462802a1f5 Add tests covering creation of tables from standard containers 2014-06-01 02:41:16 -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
a842060e4d Removed std::true_type/false_type from tuple_types and created a separate is_tuple trait, so that we can use ::type on tuple_types without it interfering with base typedefs in std::true/false_type
Fixing some identation
Moved are_same type traits to traits.hpp
2014-05-30 19:10:08 -04:00
ThePhD
b153b34334 Added tests to ensure the derived/base case doesn't slip by us again! 2014-05-25 14:41:06 -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
cd092d3bfb Add new_userdata to create internally memory managed userdata from sol::state 2014-04-27 05:09:28 -04:00
Rapptz
a2c26a042c Rename set_class to set_userdata 2014-04-27 04:11:30 -04:00
Rapptz
2f76b96061 Switch member function pointer and string pair in initialisation 2014-04-27 02:35:11 -04:00
Rapptz
8cd3b18f7b Fix test failure 2014-04-27 01:29:37 -04:00
Rapptz
b6c2f1c6d5 Fix formatting on tests file 2014-04-27 01:18:54 -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
Rapptz
d65f6f1291 Format changes on tests 2014-04-25 21:23:57 -04:00
ThePhD
2243bec052 userdata<T> now works and compiles on MSVC.
It's going to take serious work to make it happen in GCC, plus the fact that 4.9 is still giving me
so many errors I can't even read it...
 I'll let Rapptz figure it out, but later.
Sexy class bindings, yes!
2014-04-25 20:08:07 -04:00
Rapptz
2782fed879 Fix typo in tests 2014-01-18 23:10:49 -05:00
ThePhD
750d110a92 Fixing formatting to make sure everything's nice and pretty. 2013-12-21 22:11:20 -05:00
ThePhD
3d44c6500e And a last fix for the test we had to block while fixing implicit conversions, and we're good! 2013-12-21 22:05:19 -05:00
ThePhD
94c287810f It took a lott of work, but we finally have the right rankings for operator[] to work as intended with as minimal room for screwups as possible.
This should enable operator[] to work in all cases that it is to be expected, thanks to a lot of explicit conversions and some basic overload resolution ranking tricks (e.g., making some conversions a template).
We also need to remember that GCC expects `. template (function name)` in generic code, as it can parse things in a really dumb and silly manner.
2013-12-21 22:00:28 -05:00
ThePhD
b90f789986 operator[] support~
And all is as it should be in the world~
2013-12-21 19:30:30 -05:00
Rapptz
ac975872ad Remove support for operator[] on tables 2013-12-16 11:07:10 -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
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
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
913611c042 Forgot to make sure this test was running! 2013-12-14 22:21:06 -05:00
ThePhD
84f367ca23 Somehow, run_script got deelted on this file. Strange. 2013-12-14 00:32:45 -05:00
ThePhD
0079593966 Strangely enough, it's impossible for the API to know if the returned value is wrong, so this test will always fail (unless we do some crazy nonsense). 2013-12-14 00:19:02 -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
6c06bddd6e Some extra-strength "nothrow" requirements. 2013-12-13 23:33:06 -05:00
ThePhD
9624dd93e7 VC++ Compat again. 2013-12-13 20:09:51 -05:00
ThePhD
4dab754b86 VC++ Compatibility and some changes to function I'll need to test. 2013-12-13 17:50:24 -05:00
Rapptz
ebbceeb9e2 Add support for const table operator[] retrieval 2013-12-13 15:40:20 -05:00
ThePhD
2192e98eec MSVC needs explicit overloads and explicit =default operators on sol::function. It's quite whacky, really. Anyway, it compiles, so let's just make sure this works for GCC too. 2013-12-13 14:16:59 -05:00
Rapptz
8db67834b2 Add test cases for operator[] 2013-12-12 20:20:46 -05:00
Rapptz
ffb32f45ad Renamed sol.scratch.cpp to tests.cpp 2013-12-12 05:40:05 -05:00