Skip to content

Commit 9169e3e

Browse files
committed
Remove "noexcept" in the type when passing a function to luabind
1 parent f423725 commit 9169e3e

File tree

2 files changed

+37
-9
lines changed

2 files changed

+37
-9
lines changed

src/Common/object_type_traits.h

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,35 @@ struct remove_const<T const>
112112
typedef T type;
113113
};
114114

115+
template <typename T>
116+
struct remove_noexcept;
117+
118+
template <typename R, typename... Args>
119+
struct remove_noexcept<R(Args...) noexcept>
120+
{
121+
using type = R(Args...);
122+
};
123+
124+
template< typename R, typename... Args>
125+
struct remove_noexcept <R(*)(Args...) noexcept>
126+
{
127+
using type = R(*)(Args...);
128+
};
129+
130+
template <typename C, typename R, typename... Args>
131+
struct remove_noexcept<R(C::*)(Args...) noexcept>
132+
{
133+
using type = R(C::*)(Args...);
134+
};
135+
136+
template <typename C, typename R, typename... Args>
137+
struct remove_noexcept<R(C::*)(Args...) const noexcept>
138+
{
139+
using type = R(C::*)(Args...) const;
140+
};
141+
142+
#define REMOVE_NOEXCEPT(fn) (object_type_traits::remove_noexcept<decltype(fn)>::type)(fn)
143+
115144
template <typename T>
116145
struct is_void
117146
{

src/xrServerEntities/script_flags_script.cpp

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#include "pch_script.h"
1010
#include "xrScriptEngine/ScriptExporter.hpp"
11+
#include "Common/object_type_traits.h"
1112

1213
using namespace luabind;
1314

@@ -53,15 +54,14 @@ void one(T* self)
5354
self->assign(typename T::TYPE(-1));
5455
}
5556

56-
#ifndef LINUX // FIXME!!!
5757
SCRIPT_EXPORT(Flags8, (),
5858
{
5959
module(luaState)
6060
[
6161
class_<Flags8>("flags8")
6262
.def(constructor<>())
63-
.def("get", &Flags8::get)
64-
.def("zero", &Flags8::zero)
63+
.def("get", REMOVE_NOEXCEPT(&Flags8::get))
64+
.def("zero", REMOVE_NOEXCEPT(&Flags8::zero))
6565
.def("one", &one<Flags8>)
6666
.def("invert", (Flags8 & (Flags8::*)())(&Flags8::invert))
6767
.def("invert", (Flags8 & (Flags8::*)(const Flags8&))(&Flags8::invert))
@@ -87,8 +87,8 @@ SCRIPT_EXPORT(Flags16, (),
8787
[
8888
class_<Flags16>("flags16")
8989
.def(constructor<>())
90-
.def("get", &Flags16::get)
91-
.def("zero", &Flags16::zero)
90+
.def("get", REMOVE_NOEXCEPT(&Flags16::get))
91+
.def("zero", REMOVE_NOEXCEPT(&Flags16::zero))
9292
.def("one", &one<Flags16>)
9393
.def("invert", (Flags16 & (Flags16::*)())(&Flags16::invert))
9494
.def("invert", (Flags16 & (Flags16::*)(const Flags16&))(&Flags16::invert))
@@ -114,9 +114,9 @@ SCRIPT_EXPORT(Flags32, (),
114114
[
115115
class_<Flags32>("flags32")
116116
.def(constructor<>())
117-
.def("get", &Flags32::get)
118-
.def("zero", &Flags32::zero)
119-
.def("one", &Flags32::one)
117+
.def("get", REMOVE_NOEXCEPT(&Flags32::get))
118+
.def("zero", REMOVE_NOEXCEPT(&Flags32::zero))
119+
.def("one", REMOVE_NOEXCEPT(&Flags32::one))
120120
.def("invert", (Flags32 & (Flags32::*)())(&Flags32::invert))
121121
.def("invert", (Flags32 & (Flags32::*)(const Flags32&))(&Flags32::invert))
122122
.def("invert", (Flags32 & (Flags32::*)(const Flags32::TYPE))(&Flags32::invert))
@@ -134,4 +134,3 @@ SCRIPT_EXPORT(Flags32, (),
134134
.def("equal", (bool(*)(Flags32*, const Flags32&, const Flags32::TYPE))(&equal<Flags32>))
135135
];
136136
});
137-
#endif

0 commit comments

Comments
 (0)