Commit Graph

228 Commits

Author SHA1 Message Date
ThePhD
8f59cf2eee Set the ability to give your own panic function 2015-10-22 21:53:12 -04:00
ThePhD
42a03a2618 proper default error handler 2015-10-22 21:46:40 -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
7f4d8d8f89 Allow for failed function calls from lua. 2015-10-22 06:49:53 -04:00
ThePhD
93fe7443f0 Solve's @starwing's problem with not having the ability to check if a function call succeeded or not. 2015-10-22 06:10:30 -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
8e0cc99215 Seems like there's no more optimizations that can be made to sol/function...
Only other thing to optimize is `usertype`, maybe.
2015-09-29 18:19:07 -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
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
1b8bc7c1e9 cxxabi include should not be used on VC++ 2015-07-11 05:28:06 -04:00
ThePhD
9a0dda1f3d Fix VC++ warning 2015-07-09 18:18:34 -04:00
ThePhD
feefb4859f Oh, tabs. Oh, you... 2015-07-07 01:41:36 -04:00
ThePhD
6a16a5a482 Some quick fixes and harmless polishes for the compat layer in state.hpp 2015-07-07 00:31:50 -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
b8d81cb927 partial implementation of lua_version...
It's a bit more reliable than before, but... not really that much better!
2015-05-24 23:31:18 -04:00
ThePhD
8b13e6df6f Fix tab derps. 2015-05-24 21:38:39 -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
1792259685 Fix tabs. 2015-05-15 12:43:53 -04:00
ThePhD
542d2a813e new table.for_each while iterators get sorted out 2015-05-15 12:41:45 -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
fa8416168e Merge remote-tracking branch 'root/master' into api-fix
Conflicts:
	sol/function_types.hpp
2015-02-28 18:21:39 -05:00
ThePhD
0cfcadb7eb Prevent null string return from causing undefined behavior. 2014-12-17 16:57:14 -05:00
ThePhD
8a4595dc80 Merge branch 'master' into api-fix 2014-12-17 16:24:53 -05:00
ThePhD
99424524f3 Remove unused parameter warning. 2014-10-30 13:17:52 -04:00
ThePhD
699ae140c8 Use 2 string types to properly filter bad name-based usertype overloads. 2014-09-29 23:10:33 -04:00
ThePhD
a217fa5c7a Proper deprecation to alert users to API name changes. 2014-09-29 23:10:32 -04:00
ThePhD
746ef74a61 Headerguard derp; fixed. 2014-09-29 23:10:31 -04: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
ThePhD
1e3466d173 std::size_t for life.
Clang's silly tautological error can die in a fire. D:<
2014-09-29 23:05:00 -04:00
Rapptz
a11faabb5c Fix implicit conversion warnings for getter. 2014-09-29 22:45:06 -04:00
Peter Ferenc Hajdu
5fb0fef8aa fix tautological compare error 2014-09-29 22:45:05 -04:00
Rapptz
351c5af8f6 Fix implicit conversion warnings for getter. 2014-09-29 22:24:32 -04:00
Peter Ferenc Hajdu
6b6efccb66 fix tautological compare error 2014-09-29 13:04:48 +02:00
ThePhD
4a7154b219 Add additional type to allow for types themselves to be declared deprecated (through using statements and the like). 2014-09-19 11:11:38 -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
ThePhD
ad83552072 Remove bogus userdata<T> specialization; that's not longer how we're detecting userdata.
Fixed Readme example, removed bad uses of `local`
2014-09-06 22:11:16 -07:00
Rapptz
e9c3bed27e Remove noexcept that can't be met. 2014-09-05 15:53:19 -04:00
Rapptz
084a9407c6 Have to add constructor to make const variables work. 2014-09-05 15:50:40 -04:00
Rapptz
a2237eb068 Fix lack of inline in functions.
diff --git a/bootstrap.py b/bootstrap.py
index c24f6e5..1d6a0b3 100755
--- a/bootstrap.py
+++ b/bootstrap.py
@@ -37,6 +37,7 @@ parser = argparse.ArgumentParser()
 parser.add_argument('--debug', action='store_true', help='compile with debug flags')
 parser.add_argument('--cxx', metavar='<compiler>', help='compiler name to use (default: g++)', default='g++')
 parser.add_argument('--ci', action='store_true', help=argparse.SUPPRESS)
+parser.add_argument('--testing', action='store_true', help=argparse.SUPPRESS)
 parser.add_argument('--lua-dir', metavar='<dir>', help='directory lua is in with include and lib subdirectories')
 parser.add_argument('--install-dir', metavar='<dir>', help='directory to install the headers to', default=install_dir);
 parser.epilog = """In order to install sol, administrative privileges might be required.
@@ -80,6 +81,9 @@ if args.ci:
 else:
     ldflags.extend(libraries(['lua']))

+if args.testing:
+    cxxflags.append('-Wmissing-declarations')
+
 if 'linux' in sys.platform:
     ldflags.extend(libraries(['dl']))

diff --git a/sol/demangle.hpp b/sol/demangle.hpp
index 694a2be..78f4dd4 100644
--- a/sol/demangle.hpp
+++ b/sol/demangle.hpp
@@ -33,12 +33,12 @@
 namespace sol {
 namespace detail {
 #ifdef _MSC_VER
-std::string get_type_name(const std::type_info& id) {
+inline std::string get_type_name(const std::type_info& id) {
     return id.name();
 }

 #elif defined(__GNUC__) || defined(__clang__)
-std::string get_type_name(const std::type_info& id) {
+inline std::string get_type_name(const std::type_info& id) {
     int status;
     char* unmangled = abi::__cxa_demangle(id.name(), 0, 0, &status);
     std::string realname = unmangled;
@@ -50,7 +50,7 @@ std::string get_type_name(const std::type_info& id) {
 #error Compiler not supported for demangling
 #endif // compilers

-std::string demangle(const std::type_info& id) {
+inline std::string demangle(const std::type_info& id) {
     std::string realname = get_type_name(id);
     const static std::array<std::string, 2> removals = {{ "struct ", "class " }};
     const static std::array<std::string, 2> replacements = {{ "::", "_" }};
diff --git a/sol/resolve.hpp b/sol/resolve.hpp
index 0d849d0..1f6f606 100644
--- a/sol/resolve.hpp
+++ b/sol/resolve.hpp
@@ -28,66 +28,67 @@
 namespace sol {
 namespace detail {
 template<typename R, typename... Args, typename F, typename = typename std::result_of<Unqualified<F>(Args...)>::type>
-auto resolve_i(types<R(Args...)>, F&&)->R(Unqualified<F>::*)(Args...) {
+inline auto resolve_i(types<R(Args...)>, F&&) -> R(Unqualified<F>::*)(Args...) {
     using Sig = R(Args...);
     typedef Unqualified<F> Fu;
     return static_cast<Sig Fu::*>(&Fu::operator());
 }

 template<typename F, typename U = Unqualified<F>>
-auto resolve_f(std::true_type, F&& f) -> decltype(resolve_i(types<function_signature_t<decltype(&U::operator())>>(), std::forward<F>(f))) {
+inline auto resolve_f(std::true_type, F&& f)
+-> decltype(resolve_i(types<function_signature_t<decltype(&U::operator())>>(), std::forward<F>(f))) {
     return resolve_i(types<function_signature_t<decltype(&U::operator())>>(), std::forward<F>(f));
 }

 template<typename F>
-void resolve_f(std::false_type, F&&) {
+inline void resolve_f(std::false_type, F&&) {
     static_assert(has_deducible_signature<F>::value,
                   "Cannot use no-template-parameter call with an overloaded functor: specify the signature");
 }

 template<typename F, typename U = Unqualified<F>>
-auto resolve_i(types<>, F&& f) -> decltype(resolve_f(has_deducible_signature<U> {}, std::forward<F>(f))) {
+inline auto resolve_i(types<>, F&& f) -> decltype(resolve_f(has_deducible_signature<U> {}, std::forward<F>(f))) {
     return resolve_f(has_deducible_signature<U> {}, std::forward<F>(f));
 }

 template<typename... Args, typename F, typename R = typename std::result_of<F&(Args...)>::type>
-auto resolve_i(types<Args...>, F&& f) -> decltype( resolve_i(types<R(Args...)>(), std::forward<F>(f))) {
+inline auto resolve_i(types<Args...>, F&& f) -> decltype( resolve_i(types<R(Args...)>(), std::forward<F>(f))) {
     return resolve_i(types<R(Args...)>(), std::forward<F>(f));
 }

 template<typename Sig, typename C>
-Sig C::* resolve_v(std::false_type, Sig C::* mem_func_ptr) {
+inline Sig C::* resolve_v(std::false_type, Sig C::* mem_func_ptr) {
     return mem_func_ptr;
 }

 template<typename Sig, typename C>
-Sig C::* resolve_v(std::true_type, Sig C::* mem_variable_ptr) {
+inline Sig C::* resolve_v(std::true_type, Sig C::* mem_variable_ptr) {
     return mem_variable_ptr;
 }
 } // detail

 template<typename... Args, typename R>
-auto resolve(R fun_ptr(Args...)) -> R(*)(Args...) {
+inline auto resolve(R fun_ptr(Args...)) -> R(*)(Args...) {
     return fun_ptr;
 }

 template<typename Sig>
-Sig* resolve(Sig* fun_ptr) {
+inline Sig* resolve(Sig* fun_ptr) {
     return fun_ptr;
 }

 template<typename... Args, typename R, typename C>
-auto resolve(R(C::*mem_ptr)(Args...)) -> R(C::*)(Args...) {
+inline auto resolve(R(C::*mem_ptr)(Args...)) -> R(C::*)(Args...) {
     return mem_ptr;
 }

 template<typename Sig, typename C>
-Sig C::* resolve(Sig C::* mem_ptr) {
+inline Sig C::* resolve(Sig C::* mem_ptr) {
     return detail::resolve_v(std::is_member_object_pointer<Sig C::*>(), mem_ptr);
 }

 template<typename... Sig, typename F>
-auto resolve(F&& f) -> decltype(detail::resolve_i(types<Sig...>(), std::forward<F>(f))) {
+inline auto resolve(F&& f) -> decltype(detail::resolve_i(types<Sig...>(), std::forward<F>(f))) {
     return detail::resolve_i(types<Sig...>(), std::forward<F>(f));
 }
 } // sol
2014-08-10 21:07:19 -04:00
Rapptz
da76793c30 Formatting changes. 2014-08-10 20:49:34 -04:00
ThePhD
715efa6e20 I do believe C++'s inconsistencies will destroy me utterly one day.
But it is not this day. C++14 allows for not specifying the `&` in front of the member function
2014-08-09 05:49:10 -07:00