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
ThePhD
f18bcedd46
has_deducible versus is_class
2014-08-09 05:26:30 -07: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
c123fd9204
Fix unused parameter warnings on clang.
2014-08-05 09:22:43 -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
7d7e46d06a
Slay some extra spaces.
2014-08-05 00:31:59 -07:00
ThePhD
2a73410a4b
Merge remote-tracking branch 'root/master'
...
Conflicts:
sol/userdata.hpp
2014-08-05 00:15:34 -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
Rapptz
2ac3e27229
Update travis script, fix warnings.
2014-08-04 21:05:47 -04:00
Ryan Alexander
9819699105
Add include for std::free from <cstdlib>
2014-08-04 18:12:11 -04:00
ThePhD
14b1a3fe0c
Some missing support for reference-style (l-value reference and pointer) calls from lua. Fixed.
2014-07-30 00:19:58 -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
84ae20a57a
Extraneous Cx
.
2014-07-01 05:23:27 -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
36e45d88b2
userdata no longer needs to be kept around for its lifetime
...
can be discarded and lua VM will keep all necessary information
2014-06-27 21:27:48 -07:00
ThePhD
d548fdaee8
Fix spacing issues
2014-06-27 01:36:09 -07:00
ThePhD
b5a938b285
Fix spacing issues
2014-06-27 01:34:16 -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
05dcba2fac
Fix compiler error with clang
2014-06-25 17:07:21 -04: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
e5bb46afda
better Or
implementation
...
i don't think i use it anymore though...
2014-06-09 06:29:04 -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
3306b44162
okay std::function returns work
...
i want to use an is_function trait to differentiate classes when they get pushed
problem i feel that is_function may capture things not necessarily intended to be function objects
right now it is only qualified by pusher<function_t>
if change is necessary, then it becomes pusher<T, EnableIf<IsFunction<T>>>
2014-06-09 06:29:00 -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
76b1efe12e
Revamp EnableIf and DisableIf to use a much better variadic condition checking
2014-05-31 22:04:10 -04:00
Rapptz
eedb2a1796
Add key value pair trait
2014-05-31 21:10:42 -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
9c7e5f0b33
Fixed some bad formatting and a missing include guard.
2014-05-31 18:07:50 -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
Rapptz
08c94e1a67
Renamed demangling function
2014-05-31 06:08:12 -04:00
Rapptz
03f047ed05
Fix compiler error in GCC
2014-05-30 23:35:26 -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
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
ThePhD
61ecd1c87e
Bug with pop_call when concerning certain argument orders. Popping of the end of the stack was too dangerous, so instead we use a get call and pop all stack arguments off afterwards: helps to preserve order.
2014-05-30 18:20:12 -04:00
ThePhD
fb1eb21f34
Additions for stack to properly handle std::function getters. std::function gets assume that the argument is a lua function and attempt to convert it to the type of function requested by the std::function's signature
2014-05-30 18:19:12 -04:00
ThePhD
5d5ce9cd2e
get
variant to easily get std::function from sol::function when using lua's call syntax.
2014-05-30 15:30:14 -04:00
Rapptz
089b075317
Fix explicit operator bool to be negated is<nil_t>()
2014-05-29 22:19:21 -04:00
Rapptz
af1f13d582
Allow member functions that return *this to be binded properly. At the moment this means no member function chaining on the lua side
2014-05-29 04:13:24 -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
ThePhD
a8e9c01d0d
Merge remote-tracking branch 'root/master'
2014-05-29 02:32:16 -04:00
ThePhD
c5d43bcfb6
as uses auto and decltype for return type
2014-05-29 02:32:05 -04:00
Rapptz
f9b6cf1595
Add a newline to every sol file missing one
2014-05-29 01:47:27 -04:00
Rapptz
accfd0f7a7
Add explicit operator bool for sol::object for even easier nil checking
2014-05-29 01:28:13 -04:00
Rapptz
54f030873f
Remove reference when creating new reference types on the stack
2014-05-29 01:26:46 -04:00
ThePhD
41e1ca2baa
Additions for gitignore for the new files that are necessary to kick around qtCreator
...
Fix for userdata to accept base classes where the derived class uses the name of a base member function to access it (Derived::get_num, where get_num is only implemented in Base::get_num)
VC++ makes this acceptance easy by taking the name as "Derived", but GCC and Clang
2014-05-25 13:46:23 -04:00
ThePhD
b68a57c65c
Fixed rename mishap
2014-05-25 12:30:44 -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
ThePhD
d7ea4718c8
multi_return<>
name to return_type<>
.
...
Makes more sense, as the return does not always have to be multiple types.
(Indeed, it is specialized for 1 and 0 cases).
2014-05-08 13:08:21 -04:00
ThePhD
be839bdcd2
We no longer need the register_into(const table& s)
function: removing~
2014-04-27 09:13:45 -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
0ff295f61e
Switch from static member strings to userdata_traits
2014-04-27 05:08:39 -04:00
Rapptz
a2c26a042c
Rename set_class to set_userdata
2014-04-27 04:11:30 -04:00
Rapptz
6a280dc131
Format changes
2014-04-27 03:25:47 -04:00
Rapptz
2f76b96061
Switch member function pointer and string pair in initialisation
2014-04-27 02:35:11 -04:00
Rapptz
b323a62b2a
Fix compiler error with cv-qualifiers on member function pointers
2014-04-27 02:26:06 -04:00
Rapptz
8cd3b18f7b
Fix test failure
2014-04-27 01:29:37 -04:00
Rapptz
63bc2b06cb
Fix compiler errors, tests failing however
2014-04-27 00:53:57 -04:00
ThePhD
a525760178
Fixed some bad spacing.
2014-04-26 21:38:37 -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
4d6d39be88
Merge remote-tracking branch 'root/classes'
2014-04-26 00:19:45 -04:00
ThePhD
4c102605e8
Custom constructors, but apparently there's something on the stack and we can't get at its type?
2014-04-26 00:19:36 -04:00
Rapptz
077f5fd258
Massive renaming of lua_function.hpp
2014-04-25 22:05:58 -04:00
Rapptz
5229cace49
Moved pop from reference to table
2014-04-25 21:40:52 -04:00
Rapptz
c9bf032d36
Fix all compile errors on GCC
2014-04-25 20:53:36 -04:00
Rapptz
6b54f99e50
Do some renaming of lua_function.hpp and fix some compiler errors
2014-04-25 20:42:38 -04:00
Rapptz
44eab5a164
Refactor demangle.hpp to look a bit nicer
2014-04-25 20:19:31 -04:00
Rapptz
23ed27df89
Renamed DEPRECATE to SOL_DEPRECATED
2014-04-25 20:11:00 -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