Skip to content

Commit

Permalink
Remove "noexcept" in the type when passing a function to luabind
Browse files Browse the repository at this point in the history
  • Loading branch information
Zegeri committed Sep 20, 2018
1 parent f423725 commit 9169e3e
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 9 deletions.
29 changes: 29 additions & 0 deletions src/Common/object_type_traits.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,35 @@ struct remove_const<T const>
typedef T type;
};

template <typename T>
struct remove_noexcept;

template <typename R, typename... Args>
struct remove_noexcept<R(Args...) noexcept>
{
using type = R(Args...);
};

template< typename R, typename... Args>
struct remove_noexcept <R(*)(Args...) noexcept>
{
using type = R(*)(Args...);
};

template <typename C, typename R, typename... Args>
struct remove_noexcept<R(C::*)(Args...) noexcept>
{
using type = R(C::*)(Args...);
};

template <typename C, typename R, typename... Args>
struct remove_noexcept<R(C::*)(Args...) const noexcept>
{
using type = R(C::*)(Args...) const;
};

#define REMOVE_NOEXCEPT(fn) (object_type_traits::remove_noexcept<decltype(fn)>::type)(fn)

template <typename T>
struct is_void
{
Expand Down
17 changes: 8 additions & 9 deletions src/xrServerEntities/script_flags_script.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include "pch_script.h"
#include "xrScriptEngine/ScriptExporter.hpp"
#include "Common/object_type_traits.h"

using namespace luabind;

Expand Down Expand Up @@ -53,15 +54,14 @@ void one(T* self)
self->assign(typename T::TYPE(-1));
}

#ifndef LINUX // FIXME!!!
SCRIPT_EXPORT(Flags8, (),
{
module(luaState)
[
class_<Flags8>("flags8")
.def(constructor<>())
.def("get", &Flags8::get)
.def("zero", &Flags8::zero)
.def("get", REMOVE_NOEXCEPT(&Flags8::get))
.def("zero", REMOVE_NOEXCEPT(&Flags8::zero))
.def("one", &one<Flags8>)
.def("invert", (Flags8 & (Flags8::*)())(&Flags8::invert))
.def("invert", (Flags8 & (Flags8::*)(const Flags8&))(&Flags8::invert))
Expand All @@ -87,8 +87,8 @@ SCRIPT_EXPORT(Flags16, (),
[
class_<Flags16>("flags16")
.def(constructor<>())
.def("get", &Flags16::get)
.def("zero", &Flags16::zero)
.def("get", REMOVE_NOEXCEPT(&Flags16::get))
.def("zero", REMOVE_NOEXCEPT(&Flags16::zero))
.def("one", &one<Flags16>)
.def("invert", (Flags16 & (Flags16::*)())(&Flags16::invert))
.def("invert", (Flags16 & (Flags16::*)(const Flags16&))(&Flags16::invert))
Expand All @@ -114,9 +114,9 @@ SCRIPT_EXPORT(Flags32, (),
[
class_<Flags32>("flags32")
.def(constructor<>())
.def("get", &Flags32::get)
.def("zero", &Flags32::zero)
.def("one", &Flags32::one)
.def("get", REMOVE_NOEXCEPT(&Flags32::get))
.def("zero", REMOVE_NOEXCEPT(&Flags32::zero))
.def("one", REMOVE_NOEXCEPT(&Flags32::one))
.def("invert", (Flags32 & (Flags32::*)())(&Flags32::invert))
.def("invert", (Flags32 & (Flags32::*)(const Flags32&))(&Flags32::invert))
.def("invert", (Flags32 & (Flags32::*)(const Flags32::TYPE))(&Flags32::invert))
Expand All @@ -134,4 +134,3 @@ SCRIPT_EXPORT(Flags32, (),
.def("equal", (bool(*)(Flags32*, const Flags32&, const Flags32::TYPE))(&equal<Flags32>))
];
});
#endif

0 comments on commit 9169e3e

Please sign in to comment.