From 9169e3e408f26e13110271931a32868ed30d7222 Mon Sep 17 00:00:00 2001 From: Zegeri Date: Thu, 20 Sep 2018 17:47:32 +0200 Subject: [PATCH] Remove "noexcept" in the type when passing a function to luabind --- src/Common/object_type_traits.h | 29 ++++++++++++++++++++ src/xrServerEntities/script_flags_script.cpp | 17 ++++++------ 2 files changed, 37 insertions(+), 9 deletions(-) diff --git a/src/Common/object_type_traits.h b/src/Common/object_type_traits.h index 8b044e41ea5..064a763bd3e 100644 --- a/src/Common/object_type_traits.h +++ b/src/Common/object_type_traits.h @@ -112,6 +112,35 @@ struct remove_const typedef T type; }; +template +struct remove_noexcept; + +template +struct remove_noexcept +{ + using type = R(Args...); +}; + +template< typename R, typename... Args> +struct remove_noexcept +{ + using type = R(*)(Args...); +}; + +template +struct remove_noexcept +{ + using type = R(C::*)(Args...); +}; + +template +struct remove_noexcept +{ + using type = R(C::*)(Args...) const; +}; + +#define REMOVE_NOEXCEPT(fn) (object_type_traits::remove_noexcept::type)(fn) + template struct is_void { diff --git a/src/xrServerEntities/script_flags_script.cpp b/src/xrServerEntities/script_flags_script.cpp index c38dee66496..5921bfcccef 100644 --- a/src/xrServerEntities/script_flags_script.cpp +++ b/src/xrServerEntities/script_flags_script.cpp @@ -8,6 +8,7 @@ #include "pch_script.h" #include "xrScriptEngine/ScriptExporter.hpp" +#include "Common/object_type_traits.h" using namespace luabind; @@ -53,15 +54,14 @@ void one(T* self) self->assign(typename T::TYPE(-1)); } -#ifndef LINUX // FIXME!!! SCRIPT_EXPORT(Flags8, (), { module(luaState) [ class_("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) .def("invert", (Flags8 & (Flags8::*)())(&Flags8::invert)) .def("invert", (Flags8 & (Flags8::*)(const Flags8&))(&Flags8::invert)) @@ -87,8 +87,8 @@ SCRIPT_EXPORT(Flags16, (), [ class_("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) .def("invert", (Flags16 & (Flags16::*)())(&Flags16::invert)) .def("invert", (Flags16 & (Flags16::*)(const Flags16&))(&Flags16::invert)) @@ -114,9 +114,9 @@ SCRIPT_EXPORT(Flags32, (), [ class_("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)) @@ -134,4 +134,3 @@ SCRIPT_EXPORT(Flags32, (), .def("equal", (bool(*)(Flags32*, const Flags32&, const Flags32::TYPE))(&equal)) ]; }); -#endif