Skip to content

Commit

Permalink
VC++ is a fuccboi
Browse files Browse the repository at this point in the history
  • Loading branch information
ThePhD committed May 13, 2016
1 parent e97913c commit 938538b
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
5 changes: 5 additions & 0 deletions docs/source/features.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ what Sol supports
- Implicit conversion to the types you want
``double b = table["computed_value"];``

* :doc:`Optional<api/optional>` support: setting values, getting values of multiple (different) types
- :doc:`Lazy evaluation<api/proxy>` for nested/chained queries
``optional<int> maybe_number = table["a"]["b"]["invalid_key"];``
- Turns on safety when you want it: speed when you don't

* Support for callables (functions, lambdas, member functions)
- Pull out any Lua function with :doc:`sol::function<api/function>`
``sol::function fx = table["socket_send"];``
Expand Down
17 changes: 15 additions & 2 deletions sol/error.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,22 @@ struct direct_error_tag {};
const auto direct_error = direct_error_tag{};
} // detail
class error : public std::runtime_error {
private:
// Because VC++ is a fuccboi
std::string w;
public:
error(const std::string& str): std::runtime_error("lua: error: " + str) {}
error(detail::direct_error_tag, const std::string& str) : std::runtime_error(str) {}
error(const std::string& str) : error(detail::direct_error, "lua: error: " + str) {}
error(detail::direct_error_tag, const std::string& str) : std::runtime_error(""), w(str) {}
error(detail::direct_error_tag, std::string&& str) : std::runtime_error(""), w(std::move(str)) {}

error(const error& e) = default;
error(error&& e) = default;
error& operator=(const error& e) = default;
error& operator=(error&& e) = default;

virtual const char* what() const override {
return w.c_str();
}
};
} // sol

Expand Down
3 changes: 2 additions & 1 deletion sol/protected_function.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,9 @@ class basic_protected_function : public base_t {
target.push();
}
}
bool valid () const { return stackindex > 0;}
~handler() {
if (stackindex > 0) {
if (valid()) {
lua_remove(target.lua_state(), stackindex);
}
}
Expand Down

0 comments on commit 938538b

Please sign in to comment.