Skip to content

Commit

Permalink
Merge pull request #5 from Zegeri/clean
Browse files Browse the repository at this point in the history
Fix arguments  that are passed to luabind
  • Loading branch information
eagleivg committed Sep 21, 2018
2 parents f423725 + 9d0e0e8 commit 46ee695
Show file tree
Hide file tree
Showing 25 changed files with 132 additions and 130 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
2 changes: 1 addition & 1 deletion src/xrGame/account_manager_script.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ using namespace luabind;
using namespace luabind::policy;
using namespace gamespy_gp;

#ifndef LINUX // FIXME!!!
SCRIPT_EXPORT(account_manager, (), {
module(luaState)[class_<account_manager>("account_manager")
.def("suggest_unique_nicks", &account_manager::suggest_unique_nicks)
Expand All @@ -31,6 +30,7 @@ SCRIPT_EXPORT(account_manager, (), {
.def("stop_searching_email", &account_manager::stop_searching_email)];
});

#ifndef LINUX // FIXME!!!
SCRIPT_EXPORT(suggest_nicks_cb, (), {
module(luaState)[class_<gamespy_gp::suggest_nicks_cb>("suggest_nicks_cb")
.def(constructor<>())
Expand Down
2 changes: 1 addition & 1 deletion src/xrGame/alife_anomalous_zone.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,4 +131,4 @@ void CSE_ALifeAnomalousZone::on_spawn()
// spawn_artefacts ();
}

bool CSE_ALifeAnomalousZone::keep_saved_data_anyway() const noexcept { return true; }
bool CSE_ALifeAnomalousZone::keep_saved_data_anyway() const /* noexcept */ { return true; }
2 changes: 1 addition & 1 deletion src/xrGame/alife_object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,4 +182,4 @@ void CSE_ALifeObject::spawn_supplies(LPCSTR ini_string)
}
}

bool CSE_ALifeObject::keep_saved_data_anyway() const noexcept { return false; }
bool CSE_ALifeObject::keep_saved_data_anyway() const /* noexcept */ { return false; }
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
2 changes: 1 addition & 1 deletion src/xrServerEntities/xrServer_Object_Base.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ class CSE_Abstract : public IServerEntity, public CPureServerObject, public CScr
virtual CSE_Abstract* base();
virtual const CSE_Abstract* base() const;
virtual CSE_Abstract* init();
virtual bool match_configuration() const throw() { return true; }
virtual bool match_configuration() const /* noexcept */ { return true; }
// end of the virtual inheritance dependant code
IC int script_clsid() const
{
Expand Down
50 changes: 25 additions & 25 deletions src/xrServerEntities/xrServer_Objects_ALife.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -547,21 +547,21 @@ u32 CSE_ALifeObject::ef_detector_type() const
return (u32(-1));
}

bool CSE_ALifeObject::used_ai_locations() const noexcept
bool CSE_ALifeObject::used_ai_locations() const /* noexcept */
{ return !!m_flags.is(flUsedAI_Locations); }
bool CSE_ALifeObject::can_switch_online() const noexcept
bool CSE_ALifeObject::can_switch_online() const /* noexcept */
{ return match_configuration() && !!m_flags.is(flSwitchOnline); }
bool CSE_ALifeObject::can_switch_offline() const noexcept
bool CSE_ALifeObject::can_switch_offline() const /* noexcept */
{ return !match_configuration() || !!m_flags.is(flSwitchOffline); }
bool CSE_ALifeObject::can_save() const noexcept
bool CSE_ALifeObject::can_save() const /* noexcept */
{ return !!m_flags.is(flCanSave); }
bool CSE_ALifeObject::interactive() const noexcept
bool CSE_ALifeObject::interactive() const /* noexcept */
{ return !!m_flags.is(flInteractive) && !!m_flags.is(flVisibleForAI) && !!m_flags.is(flUsefulForAI); }

void CSE_ALifeObject::use_ai_locations(bool value) { m_flags.set(flUsedAI_Locations, BOOL(value)); }
void CSE_ALifeObject::can_switch_online(bool value) noexcept { m_flags.set(flSwitchOnline, BOOL(value)); }
void CSE_ALifeObject::can_switch_offline(bool value) noexcept { m_flags.set(flSwitchOffline, BOOL(value)); }
void CSE_ALifeObject::interactive(bool value) noexcept { m_flags.set(flInteractive, BOOL(value)); }
void CSE_ALifeObject::can_switch_online(bool value) /* noexcept */ { m_flags.set(flSwitchOnline, BOOL(value)); }
void CSE_ALifeObject::can_switch_offline(bool value) /* noexcept */ { m_flags.set(flSwitchOffline, BOOL(value)); }
void CSE_ALifeObject::interactive(bool value) /* noexcept */ { m_flags.set(flInteractive, BOOL(value)); }
////////////////////////////////////////////////////////////////////////////
// CSE_ALifeGroupAbstract
////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -703,8 +703,8 @@ void CSE_ALifePHSkeletonObject::UPDATE_Read(NET_Packet& tNetPacket)
inherited2::UPDATE_Read(tNetPacket);
};

bool CSE_ALifePHSkeletonObject::can_save() const noexcept { return CSE_PHSkeleton::need_save(); }
bool CSE_ALifePHSkeletonObject::used_ai_locations() const noexcept { return false; }
bool CSE_ALifePHSkeletonObject::can_save() const /* noexcept */ { return CSE_PHSkeleton::need_save(); }
bool CSE_ALifePHSkeletonObject::used_ai_locations() const /* noexcept */ { return false; }
#ifndef XRGAME_EXPORTS
void CSE_ALifePHSkeletonObject::FillProps(LPCSTR pref, PropItemVec& items)
{
Expand All @@ -726,8 +726,8 @@ CSE_ALifeSpaceRestrictor::CSE_ALifeSpaceRestrictor(LPCSTR caSection) : CSE_ALife
}

CSE_ALifeSpaceRestrictor::~CSE_ALifeSpaceRestrictor() {}
bool CSE_ALifeSpaceRestrictor::can_switch_offline() const noexcept { return false; }
bool CSE_ALifeSpaceRestrictor::used_ai_locations() const noexcept { return false; }
bool CSE_ALifeSpaceRestrictor::can_switch_offline() const /* noexcept */ { return false; }
bool CSE_ALifeSpaceRestrictor::used_ai_locations() const /* noexcept */ { return false; }
IServerEntityShape* CSE_ALifeSpaceRestrictor::shape() { return (this); }
void CSE_ALifeSpaceRestrictor::STATE_Read(NET_Packet& tNetPacket, u16 size)
{
Expand Down Expand Up @@ -1148,8 +1148,8 @@ void CSE_ALifeObjectPhysic::FillProps(LPCSTR pref, PropItemVec& values)
}
#endif // #ifndef XRGAME_EXPORTS

bool CSE_ALifeObjectPhysic::used_ai_locations() const noexcept { return false; }
bool CSE_ALifeObjectPhysic::can_save() const noexcept { return CSE_PHSkeleton::need_save(); }
bool CSE_ALifeObjectPhysic::used_ai_locations() const /* noexcept */ { return false; }
bool CSE_ALifeObjectPhysic::can_save() const /* noexcept */ { return CSE_PHSkeleton::need_save(); }
////////////////////////////////////////////////////////////////////////////
// CSE_ALifeObjectHangingLamp
////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -1418,7 +1418,7 @@ CDUInterface* du, IServerEntityLEOwner* owner, bool bSelected, const Fmatrix& pa
}
#endif // #ifndef XRGAME_EXPORTS

bool CSE_ALifeObjectHangingLamp::used_ai_locations() const noexcept { return false; }
bool CSE_ALifeObjectHangingLamp::used_ai_locations() const /* noexcept */ { return false; }
bool CSE_ALifeObjectHangingLamp::validate()
{
if (flags.test(flR1) || flags.test(flR2))
Expand All @@ -1428,7 +1428,7 @@ bool CSE_ALifeObjectHangingLamp::validate()
return (false);
}

bool CSE_ALifeObjectHangingLamp::match_configuration() const noexcept
bool CSE_ALifeObjectHangingLamp::match_configuration() const /* noexcept */
{
R_ASSERT3(flags.test(flR1) || flags.test(flR2), "no renderer type set for hanging-lamp ", name_replace());
#ifdef XRGAME_EXPORTS
Expand Down Expand Up @@ -1458,7 +1458,7 @@ void CSE_ALifeObjectProjector::UPDATE_Write(NET_Packet& tNetPacket) { inherited:
void CSE_ALifeObjectProjector::FillProps(LPCSTR pref, PropItemVec& values) { inherited::FillProps(pref, values); }
#endif // #ifndef XRGAME_EXPORTS

bool CSE_ALifeObjectProjector::used_ai_locations() const noexcept { return false; }
bool CSE_ALifeObjectProjector::used_ai_locations() const /* noexcept */ { return false; }
////////////////////////////////////////////////////////////////////////////
// CSE_ALifeSchedulable
////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -1562,7 +1562,7 @@ void CSE_ALifeHelicopter::load(NET_Packet& tNetPacket)
inherited1::load(tNetPacket);
inherited3::load(tNetPacket);
}
bool CSE_ALifeHelicopter::can_save() const noexcept { return CSE_PHSkeleton::need_save(); }
bool CSE_ALifeHelicopter::can_save() const /* noexcept */ { return CSE_PHSkeleton::need_save(); }
#ifndef XRGAME_EXPORTS
void CSE_ALifeHelicopter::FillProps(LPCSTR pref, PropItemVec& values)
{
Expand All @@ -1574,7 +1574,7 @@ void CSE_ALifeHelicopter::FillProps(LPCSTR pref, PropItemVec& values)
}
#endif // #ifndef XRGAME_EXPORTS

bool CSE_ALifeHelicopter::used_ai_locations() const noexcept { return false; }
bool CSE_ALifeHelicopter::used_ai_locations() const /* noexcept */ { return false; }
////////////////////////////////////////////////////////////////////////////
// CSE_ALifeCar
////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -1621,8 +1621,8 @@ void CSE_ALifeCar::UPDATE_Write(NET_Packet& tNetPacket)
inherited2::UPDATE_Write(tNetPacket);
}

bool CSE_ALifeCar::used_ai_locations() const noexcept { return false; }
bool CSE_ALifeCar::can_save() const noexcept { return CSE_PHSkeleton::need_save(); }
bool CSE_ALifeCar::used_ai_locations() const /* noexcept */ { return false; }
bool CSE_ALifeCar::can_save() const /* noexcept */ { return CSE_PHSkeleton::need_save(); }
void CSE_ALifeCar::load(NET_Packet& tNetPacket)
{
inherited1::load(tNetPacket);
Expand Down Expand Up @@ -1737,8 +1737,8 @@ void CSE_ALifeObjectBreakable::FillProps(LPCSTR pref, PropItemVec& values)
}
#endif // #ifndef XRGAME_EXPORTS

bool CSE_ALifeObjectBreakable::used_ai_locations() const noexcept { return false; }
bool CSE_ALifeObjectBreakable::can_switch_offline() const noexcept { return false; }
bool CSE_ALifeObjectBreakable::used_ai_locations() const /* noexcept */ { return false; }
bool CSE_ALifeObjectBreakable::can_switch_offline() const /* noexcept */ { return false; }
////////////////////////////////////////////////////////////////////////////
// CSE_ALifeObjectClimable
////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -1799,8 +1799,8 @@ void CSE_ALifeObjectClimable::set_additional_info(void* info)
}
#endif // #ifndef XRGAME_EXPORTS

bool CSE_ALifeObjectClimable::used_ai_locations() const noexcept { return false; }
bool CSE_ALifeObjectClimable::can_switch_offline() const noexcept { return false; }
bool CSE_ALifeObjectClimable::used_ai_locations() const /* noexcept */ { return false; }
bool CSE_ALifeObjectClimable::can_switch_offline() const /* noexcept */ { return false; }
////////////////////////////////////////////////////////////////////////////
// CSE_ALifeMountedWeapon
////////////////////////////////////////////////////////////////////////////
Expand Down
Loading

0 comments on commit 46ee695

Please sign in to comment.