mirror of
https://github.com/OpenMW/openmw.git
synced 2025-12-04 12:04:32 +00:00
Merge branch openmw:master into master
This commit is contained in:
commit
31580ffb71
149 changed files with 6962 additions and 5791 deletions
|
|
@ -1 +1 @@
|
||||||
VCPKG_DEPS_TAG=2024-11-10
|
VCPKG_DEPS_TAG=2025-07-23
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,7 @@ add_openmw_dir (mwlua
|
||||||
context menuscripts globalscripts localscripts playerscripts luabindings objectbindings cellbindings coremwscriptbindings
|
context menuscripts globalscripts localscripts playerscripts luabindings objectbindings cellbindings coremwscriptbindings
|
||||||
mwscriptbindings camerabindings vfsbindings uibindings soundbindings inputbindings nearbybindings dialoguebindings
|
mwscriptbindings camerabindings vfsbindings uibindings soundbindings inputbindings nearbybindings dialoguebindings
|
||||||
postprocessingbindings stats recordstore debugbindings corebindings worldbindings worker landbindings magicbindings factionbindings
|
postprocessingbindings stats recordstore debugbindings corebindings worldbindings worker landbindings magicbindings factionbindings
|
||||||
classbindings itemdata inputprocessor animationbindings birthsignbindings racebindings markupbindings
|
classbindings itemdata inputprocessor animationbindings birthsignbindings racebindings markupbindings weatherbindings
|
||||||
types/types types/door types/item types/actor types/container types/lockable types/weapon types/npc
|
types/types types/door types/item types/actor types/container types/lockable types/weapon types/npc
|
||||||
types/creature types/player types/activator types/book types/lockpick types/probe types/apparatus
|
types/creature types/player types/activator types/book types/lockpick types/probe types/apparatus
|
||||||
types/potion types/ingredient types/misc types/repair types/armor types/light types/static
|
types/potion types/ingredient types/misc types/repair types/armor types/light types/static
|
||||||
|
|
|
||||||
|
|
@ -781,7 +781,6 @@ void OMW::Engine::prepareEngine()
|
||||||
|
|
||||||
const auto userdefault = mCfgMgr.getUserConfigPath() / "gamecontrollerdb.txt";
|
const auto userdefault = mCfgMgr.getUserConfigPath() / "gamecontrollerdb.txt";
|
||||||
const auto localdefault = mCfgMgr.getLocalPath() / "gamecontrollerdb.txt";
|
const auto localdefault = mCfgMgr.getLocalPath() / "gamecontrollerdb.txt";
|
||||||
const auto globaldefault = mCfgMgr.getGlobalPath() / "gamecontrollerdb.txt";
|
|
||||||
|
|
||||||
std::filesystem::path userGameControllerdb;
|
std::filesystem::path userGameControllerdb;
|
||||||
if (std::filesystem::exists(userdefault))
|
if (std::filesystem::exists(userdefault))
|
||||||
|
|
@ -790,9 +789,13 @@ void OMW::Engine::prepareEngine()
|
||||||
std::filesystem::path gameControllerdb;
|
std::filesystem::path gameControllerdb;
|
||||||
if (std::filesystem::exists(localdefault))
|
if (std::filesystem::exists(localdefault))
|
||||||
gameControllerdb = localdefault;
|
gameControllerdb = localdefault;
|
||||||
else if (std::filesystem::exists(globaldefault))
|
else if (!mCfgMgr.getGlobalPath().empty())
|
||||||
gameControllerdb = globaldefault;
|
{
|
||||||
// else if it doesn't exist, pass in an empty string
|
const auto globaldefault = mCfgMgr.getGlobalPath() / "gamecontrollerdb.txt";
|
||||||
|
if (std::filesystem::exists(globaldefault))
|
||||||
|
gameControllerdb = globaldefault;
|
||||||
|
}
|
||||||
|
// else if it doesn't exist, pass in an empty path
|
||||||
|
|
||||||
// gui needs our shaders path before everything else
|
// gui needs our shaders path before everything else
|
||||||
mResourceSystem->getSceneManager()->setShaderPath(mResDir / "shaders");
|
mResourceSystem->getSceneManager()->setShaderPath(mResDir / "shaders");
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@
|
||||||
namespace osg
|
namespace osg
|
||||||
{
|
{
|
||||||
class Vec3f;
|
class Vec3f;
|
||||||
|
class Vec4f;
|
||||||
class Matrixf;
|
class Matrixf;
|
||||||
class Quat;
|
class Quat;
|
||||||
class Image;
|
class Image;
|
||||||
|
|
@ -93,6 +94,7 @@ namespace MWWorld
|
||||||
class RefData;
|
class RefData;
|
||||||
class Cell;
|
class Cell;
|
||||||
class DateTimeManager;
|
class DateTimeManager;
|
||||||
|
class Weather;
|
||||||
|
|
||||||
typedef std::vector<std::pair<MWWorld::Ptr, MWMechanics::Movement>> PtrMovementList;
|
typedef std::vector<std::pair<MWWorld::Ptr, MWMechanics::Movement>> PtrMovementList;
|
||||||
}
|
}
|
||||||
|
|
@ -216,9 +218,21 @@ namespace MWBase
|
||||||
|
|
||||||
virtual void changeWeather(const ESM::RefId& region, const unsigned int id) = 0;
|
virtual void changeWeather(const ESM::RefId& region, const unsigned int id) = 0;
|
||||||
|
|
||||||
virtual int getCurrentWeather() const = 0;
|
virtual void changeWeather(const ESM::RefId& region, const ESM::RefId& id) = 0;
|
||||||
|
|
||||||
virtual int getNextWeather() const = 0;
|
virtual const std::vector<MWWorld::Weather>& getAllWeather() const = 0;
|
||||||
|
|
||||||
|
virtual int getCurrentWeatherScriptId() const = 0;
|
||||||
|
|
||||||
|
virtual const MWWorld::Weather& getCurrentWeather() const = 0;
|
||||||
|
|
||||||
|
virtual const MWWorld::Weather* getWeather(size_t index) const = 0;
|
||||||
|
|
||||||
|
virtual const MWWorld::Weather* getWeather(const ESM::RefId& id) const = 0;
|
||||||
|
|
||||||
|
virtual int getNextWeatherScriptId() const = 0;
|
||||||
|
|
||||||
|
virtual const MWWorld::Weather* getNextWeather() const = 0;
|
||||||
|
|
||||||
virtual float getWeatherTransition() const = 0;
|
virtual float getWeatherTransition() const = 0;
|
||||||
|
|
||||||
|
|
@ -478,6 +492,7 @@ namespace MWBase
|
||||||
// Allow NPCs to use torches?
|
// Allow NPCs to use torches?
|
||||||
virtual bool useTorches() const = 0;
|
virtual bool useTorches() const = 0;
|
||||||
|
|
||||||
|
virtual const osg::Vec4f& getSunLightPosition() const = 0;
|
||||||
virtual float getSunVisibility() const = 0;
|
virtual float getSunVisibility() const = 0;
|
||||||
virtual float getSunPercentage() const = 0;
|
virtual float getSunPercentage() const = 0;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -501,7 +501,7 @@ int MWDialogue::Filter::getSelectStructInteger(const SelectWrapper& select) cons
|
||||||
|
|
||||||
case ESM::DialogueCondition::Function_Weather:
|
case ESM::DialogueCondition::Function_Weather:
|
||||||
|
|
||||||
return MWBase::Environment::get().getWorld()->getCurrentWeather();
|
return MWBase::Environment::get().getWorld()->getCurrentWeatherScriptId();
|
||||||
|
|
||||||
case ESM::DialogueCondition::Function_Reputation:
|
case ESM::DialogueCondition::Function_Reputation:
|
||||||
if (!mActor.getClass().isNpc())
|
if (!mActor.getClass().isNpc())
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@
|
||||||
#include "magicbindings.hpp"
|
#include "magicbindings.hpp"
|
||||||
#include "soundbindings.hpp"
|
#include "soundbindings.hpp"
|
||||||
#include "stats.hpp"
|
#include "stats.hpp"
|
||||||
|
#include "weatherbindings.hpp"
|
||||||
|
|
||||||
namespace MWLua
|
namespace MWLua
|
||||||
{
|
{
|
||||||
|
|
@ -104,6 +105,9 @@ namespace MWLua
|
||||||
|
|
||||||
api["land"] = context.cachePackage("openmw_core_land", [context]() { return initCoreLandBindings(context); });
|
api["land"] = context.cachePackage("openmw_core_land", [context]() { return initCoreLandBindings(context); });
|
||||||
|
|
||||||
|
api["weather"]
|
||||||
|
= context.cachePackage("openmw_core_weather", [context]() { return initCoreWeatherBindings(context); });
|
||||||
|
|
||||||
api["factions"]
|
api["factions"]
|
||||||
= context.cachePackage("openmw_core_factions", [context]() { return initCoreFactionBindings(context); });
|
= context.cachePackage("openmw_core_factions", [context]() { return initCoreFactionBindings(context); });
|
||||||
api["dialogue"]
|
api["dialogue"]
|
||||||
|
|
|
||||||
185
apps/openmw/mwlua/weatherbindings.cpp
Normal file
185
apps/openmw/mwlua/weatherbindings.cpp
Normal file
|
|
@ -0,0 +1,185 @@
|
||||||
|
#include "weatherbindings.hpp"
|
||||||
|
|
||||||
|
#include <osg/Vec4f>
|
||||||
|
|
||||||
|
#include <components/esm3/loadregn.hpp>
|
||||||
|
#include <components/lua/util.hpp>
|
||||||
|
#include <components/misc/color.hpp>
|
||||||
|
#include <components/misc/resourcehelpers.hpp>
|
||||||
|
#include <components/resource/resourcesystem.hpp>
|
||||||
|
|
||||||
|
#include "../mwbase/environment.hpp"
|
||||||
|
#include "../mwbase/world.hpp"
|
||||||
|
#include "../mwworld/esmstore.hpp"
|
||||||
|
#include "../mwworld/weather.hpp"
|
||||||
|
|
||||||
|
#include "context.hpp"
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
class WeatherStore
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
const MWWorld::Weather* get(size_t index) const
|
||||||
|
{
|
||||||
|
return MWBase::Environment::get().getWorld()->getWeather(index);
|
||||||
|
}
|
||||||
|
const MWWorld::Weather* get(const ESM::RefId& id) const
|
||||||
|
{
|
||||||
|
return MWBase::Environment::get().getWorld()->getWeather(id);
|
||||||
|
}
|
||||||
|
size_t size() const { return MWBase::Environment::get().getWorld()->getAllWeather().size(); }
|
||||||
|
};
|
||||||
|
|
||||||
|
Misc::Color color(const osg::Vec4f& color)
|
||||||
|
{
|
||||||
|
return Misc::Color(color.r(), color.g(), color.b(), color.a());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace MWLua
|
||||||
|
{
|
||||||
|
sol::table initCoreWeatherBindings(const Context& context)
|
||||||
|
{
|
||||||
|
sol::state_view lua = context.sol();
|
||||||
|
sol::table api(lua, sol::create);
|
||||||
|
|
||||||
|
auto vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
|
||||||
|
auto weatherT = lua.new_usertype<MWWorld::Weather>("Weather");
|
||||||
|
weatherT[sol::meta_function::to_string]
|
||||||
|
= [](const MWWorld::Weather& w) -> std::string { return "Weather[" + w.mName + "]"; };
|
||||||
|
weatherT["name"] = sol::readonly_property([](const MWWorld::Weather& w) { return w.mName; });
|
||||||
|
weatherT["windSpeed"] = sol::readonly_property([](const MWWorld::Weather& w) { return w.mWindSpeed; });
|
||||||
|
weatherT["cloudSpeed"] = sol::readonly_property([](const MWWorld::Weather& w) { return w.mCloudSpeed; });
|
||||||
|
weatherT["cloudTexture"] = sol::readonly_property([vfs](const MWWorld::Weather& w) {
|
||||||
|
return Misc::ResourceHelpers::correctTexturePath(w.mCloudTexture, vfs);
|
||||||
|
});
|
||||||
|
weatherT["cloudsMaximumPercent"]
|
||||||
|
= sol::readonly_property([](const MWWorld::Weather& w) { return w.mCloudsMaximumPercent; });
|
||||||
|
weatherT["isStorm"] = sol::readonly_property([](const MWWorld::Weather& w) { return w.mIsStorm; });
|
||||||
|
weatherT["stormDirection"]
|
||||||
|
= sol::readonly_property([](const MWWorld::Weather& w) { return w.mStormDirection; });
|
||||||
|
weatherT["glareView"] = sol::readonly_property([](const MWWorld::Weather& w) { return w.mGlareView; });
|
||||||
|
weatherT["rainSpeed"] = sol::readonly_property([](const MWWorld::Weather& w) { return w.mRainSpeed; });
|
||||||
|
weatherT["rainEntranceSpeed"]
|
||||||
|
= sol::readonly_property([](const MWWorld::Weather& w) { return w.mRainEntranceSpeed; });
|
||||||
|
weatherT["rainEffect"] = sol::readonly_property([](const MWWorld::Weather& w) -> sol::optional<std::string> {
|
||||||
|
if (w.mRainEffect.empty())
|
||||||
|
return sol::nullopt;
|
||||||
|
return w.mRainEffect;
|
||||||
|
});
|
||||||
|
weatherT["rainMaxRaindrops"]
|
||||||
|
= sol::readonly_property([](const MWWorld::Weather& w) { return w.mRainMaxRaindrops; });
|
||||||
|
weatherT["rainDiameter"] = sol::readonly_property([](const MWWorld::Weather& w) { return w.mRainDiameter; });
|
||||||
|
weatherT["rainThreshold"] = sol::readonly_property([](const MWWorld::Weather& w) { return w.mRainThreshold; });
|
||||||
|
weatherT["rainMaxHeight"] = sol::readonly_property([](const MWWorld::Weather& w) { return w.mRainMaxHeight; });
|
||||||
|
weatherT["rainMinHeight"] = sol::readonly_property([](const MWWorld::Weather& w) { return w.mRainMinHeight; });
|
||||||
|
weatherT["rainLoopSoundID"]
|
||||||
|
= sol::readonly_property([](const MWWorld::Weather& w) { return w.mRainLoopSoundID.serializeText(); });
|
||||||
|
weatherT["thunderSoundID"] = sol::readonly_property([lua](const MWWorld::Weather& w) {
|
||||||
|
sol::table result(lua, sol::create);
|
||||||
|
for (const auto& soundId : w.mThunderSoundID)
|
||||||
|
result.add(soundId.serializeText());
|
||||||
|
return result;
|
||||||
|
});
|
||||||
|
weatherT["sunDiscSunsetColor"]
|
||||||
|
= sol::readonly_property([](const MWWorld::Weather& w) { return color(w.mSunDiscSunsetColor); });
|
||||||
|
weatherT["ambientLoopSoundID"]
|
||||||
|
= sol::readonly_property([](const MWWorld::Weather& w) { return w.mAmbientLoopSoundID.serializeText(); });
|
||||||
|
weatherT["ambientColor"] = sol::readonly_property([lua](const MWWorld::Weather& w) {
|
||||||
|
sol::table result(lua, sol::create);
|
||||||
|
result["sunrise"] = color(w.mAmbientColor.getSunriseValue());
|
||||||
|
result["day"] = color(w.mAmbientColor.getDayValue());
|
||||||
|
result["sunset"] = color(w.mAmbientColor.getSunsetValue());
|
||||||
|
result["night"] = color(w.mAmbientColor.getNightValue());
|
||||||
|
return result;
|
||||||
|
});
|
||||||
|
weatherT["fogColor"] = sol::readonly_property([lua](const MWWorld::Weather& w) {
|
||||||
|
sol::table result(lua, sol::create);
|
||||||
|
result["sunrise"] = color(w.mFogColor.getSunriseValue());
|
||||||
|
result["day"] = color(w.mFogColor.getDayValue());
|
||||||
|
result["sunset"] = color(w.mFogColor.getSunsetValue());
|
||||||
|
result["night"] = color(w.mFogColor.getNightValue());
|
||||||
|
return result;
|
||||||
|
});
|
||||||
|
weatherT["skyColor"] = sol::readonly_property([lua](const MWWorld::Weather& w) {
|
||||||
|
sol::table result(lua, sol::create);
|
||||||
|
result["sunrise"] = color(w.mSkyColor.getSunriseValue());
|
||||||
|
result["day"] = color(w.mSkyColor.getDayValue());
|
||||||
|
result["sunset"] = color(w.mSkyColor.getSunsetValue());
|
||||||
|
result["night"] = color(w.mSkyColor.getNightValue());
|
||||||
|
return result;
|
||||||
|
});
|
||||||
|
weatherT["sunColor"] = sol::readonly_property([lua](const MWWorld::Weather& w) {
|
||||||
|
sol::table result(lua, sol::create);
|
||||||
|
result["sunrise"] = color(w.mSunColor.getSunriseValue());
|
||||||
|
result["day"] = color(w.mSunColor.getDayValue());
|
||||||
|
result["sunset"] = color(w.mSunColor.getSunsetValue());
|
||||||
|
result["night"] = color(w.mSunColor.getNightValue());
|
||||||
|
return result;
|
||||||
|
});
|
||||||
|
weatherT["landFogDepth"] = sol::readonly_property([lua](const MWWorld::Weather& w) {
|
||||||
|
sol::table result(lua, sol::create);
|
||||||
|
result["sunrise"] = w.mLandFogDepth.getSunriseValue();
|
||||||
|
result["day"] = w.mLandFogDepth.getDayValue();
|
||||||
|
result["sunset"] = w.mLandFogDepth.getSunsetValue();
|
||||||
|
result["night"] = w.mLandFogDepth.getNightValue();
|
||||||
|
return result;
|
||||||
|
});
|
||||||
|
weatherT["particleEffect"]
|
||||||
|
= sol::readonly_property([](const MWWorld::Weather& w) -> sol::optional<std::string> {
|
||||||
|
if (w.mParticleEffect.empty())
|
||||||
|
return sol::nullopt;
|
||||||
|
return w.mParticleEffect;
|
||||||
|
});
|
||||||
|
weatherT["distantLandFogFactor"]
|
||||||
|
= sol::readonly_property([](const MWWorld::Weather& w) { return w.mDL.FogFactor; });
|
||||||
|
weatherT["distantLandFogOffset"]
|
||||||
|
= sol::readonly_property([](const MWWorld::Weather& w) { return w.mDL.FogOffset; });
|
||||||
|
weatherT["scriptId"] = sol::readonly_property([](const MWWorld::Weather& w) { return w.mScriptId; });
|
||||||
|
weatherT["recordId"] = sol::readonly_property([](const MWWorld::Weather& w) { return w.mId.serializeText(); });
|
||||||
|
|
||||||
|
api["getCurrent"] = []() { return MWBase::Environment::get().getWorld()->getCurrentWeather(); };
|
||||||
|
api["getNext"]
|
||||||
|
= []() -> const MWWorld::Weather* { return MWBase::Environment::get().getWorld()->getNextWeather(); };
|
||||||
|
api["getTransition"] = []() { return MWBase::Environment::get().getWorld()->getWeatherTransition(); };
|
||||||
|
|
||||||
|
api["changeWeather"] = [](std::string_view regionId, const MWWorld::Weather& weather) {
|
||||||
|
ESM::RefId region = ESM::RefId::deserializeText(regionId);
|
||||||
|
MWBase::Environment::get().getESMStore()->get<ESM::Region>().find(region);
|
||||||
|
MWBase::Environment::get().getWorld()->changeWeather(region, weather.mId);
|
||||||
|
};
|
||||||
|
|
||||||
|
sol::usertype<WeatherStore> storeT = lua.new_usertype<WeatherStore>("WeatherWorldStore");
|
||||||
|
storeT[sol::meta_function::to_string]
|
||||||
|
= [](const WeatherStore& store) { return "{" + std::to_string(store.size()) + " Weather records}"; };
|
||||||
|
storeT[sol::meta_function::length] = [](const WeatherStore& store) { return store.size(); };
|
||||||
|
storeT[sol::meta_function::index] = sol::overload(
|
||||||
|
[](const WeatherStore& store, size_t index) -> const MWWorld::Weather* {
|
||||||
|
return store.get(LuaUtil::fromLuaIndex(index));
|
||||||
|
},
|
||||||
|
[](const WeatherStore& store, std::string_view id) -> const MWWorld::Weather* {
|
||||||
|
return store.get(ESM::RefId::deserializeText(id));
|
||||||
|
});
|
||||||
|
storeT[sol::meta_function::ipairs] = lua["ipairsForArray"].template get<sol::function>();
|
||||||
|
storeT[sol::meta_function::pairs] = lua["ipairsForArray"].template get<sol::function>();
|
||||||
|
|
||||||
|
// Provide access to the store.
|
||||||
|
api["records"] = WeatherStore{};
|
||||||
|
|
||||||
|
api["getCurrentSunLightDirection"] = []() {
|
||||||
|
osg::Vec4f sunPos = MWBase::Environment::get().getWorld()->getSunLightPosition();
|
||||||
|
// normalize to get the direction towards the sun
|
||||||
|
sunPos.normalize();
|
||||||
|
|
||||||
|
// and invert it to get the direction of the sun light
|
||||||
|
return -sunPos;
|
||||||
|
};
|
||||||
|
api["getCurrentSunVisibility"] = []() { return MWBase::Environment::get().getWorld()->getSunVisibility(); };
|
||||||
|
api["getCurrentSunPercentage"] = []() { return MWBase::Environment::get().getWorld()->getSunPercentage(); };
|
||||||
|
api["getCurrentWindSpeed"] = []() { return MWBase::Environment::get().getWorld()->getWindSpeed(); };
|
||||||
|
api["getCurrentStormDirection"] = []() { return MWBase::Environment::get().getWorld()->getStormDirection(); };
|
||||||
|
|
||||||
|
return LuaUtil::makeReadOnly(api);
|
||||||
|
}
|
||||||
|
}
|
||||||
14
apps/openmw/mwlua/weatherbindings.hpp
Normal file
14
apps/openmw/mwlua/weatherbindings.hpp
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
#ifndef MWLUA_WEATHERBINDINGS_H
|
||||||
|
#define MWLUA_WEATHERBINDINGS_H
|
||||||
|
|
||||||
|
#include <sol/forward.hpp>
|
||||||
|
|
||||||
|
namespace MWLua
|
||||||
|
{
|
||||||
|
struct Context;
|
||||||
|
|
||||||
|
sol::table initCoreWeatherBindings(const Context&);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // MWLUA_WEATHERBINDINGS_H
|
||||||
|
|
@ -73,6 +73,21 @@ namespace
|
||||||
|
|
||||||
namespace MWMechanics
|
namespace MWMechanics
|
||||||
{
|
{
|
||||||
|
struct ActiveSpells::UpdateContext
|
||||||
|
{
|
||||||
|
bool mUpdatedEnemy = false;
|
||||||
|
bool mUpdatedHitOverlay = false;
|
||||||
|
bool mUpdateSpellWindow = false;
|
||||||
|
bool mPlayNonLooping = false;
|
||||||
|
bool mEraseRemoved = false;
|
||||||
|
bool mUpdate;
|
||||||
|
|
||||||
|
UpdateContext(bool update)
|
||||||
|
: mUpdate(update)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
ActiveSpells::IterationGuard::IterationGuard(ActiveSpells& spells)
|
ActiveSpells::IterationGuard::IterationGuard(ActiveSpells& spells)
|
||||||
: mActiveSpells(spells)
|
: mActiveSpells(spells)
|
||||||
{
|
{
|
||||||
|
|
@ -256,8 +271,9 @@ namespace MWMechanics
|
||||||
++spellIt;
|
++spellIt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UpdateContext context(duration > 0.f);
|
||||||
for (const auto& spell : mQueue)
|
for (const auto& spell : mQueue)
|
||||||
addToSpells(ptr, spell);
|
addToSpells(ptr, spell, context);
|
||||||
mQueue.clear();
|
mQueue.clear();
|
||||||
|
|
||||||
// Vanilla only does this on cell change I think
|
// Vanilla only does this on cell change I think
|
||||||
|
|
@ -267,20 +283,17 @@ namespace MWMechanics
|
||||||
if (spell->mData.mType != ESM::Spell::ST_Spell && spell->mData.mType != ESM::Spell::ST_Power
|
if (spell->mData.mType != ESM::Spell::ST_Spell && spell->mData.mType != ESM::Spell::ST_Power
|
||||||
&& !isSpellActive(spell->mId))
|
&& !isSpellActive(spell->mId))
|
||||||
{
|
{
|
||||||
mSpells.emplace_back(ActiveSpellParams{ spell, ptr, true });
|
initParams(ptr, ActiveSpellParams{ spell, ptr, true }, context);
|
||||||
mSpells.back().setActiveSpellId(MWBase::Environment::get().getESMStore()->generateId());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool updateSpellWindow = false;
|
|
||||||
bool playNonLooping = false;
|
|
||||||
if (ptr.getClass().hasInventoryStore(ptr)
|
if (ptr.getClass().hasInventoryStore(ptr)
|
||||||
&& !(creatureStats.isDead() && !creatureStats.isDeathAnimationFinished()))
|
&& !(creatureStats.isDead() && !creatureStats.isDeathAnimationFinished()))
|
||||||
{
|
{
|
||||||
auto& store = ptr.getClass().getInventoryStore(ptr);
|
auto& store = ptr.getClass().getInventoryStore(ptr);
|
||||||
if (store.getInvListener() != nullptr)
|
if (store.getInvListener() != nullptr)
|
||||||
{
|
{
|
||||||
playNonLooping = !store.isFirstEquip();
|
context.mPlayNonLooping = !store.isFirstEquip();
|
||||||
const auto world = MWBase::Environment::get().getWorld();
|
const auto world = MWBase::Environment::get().getWorld();
|
||||||
for (int slotIndex = 0; slotIndex < MWWorld::InventoryStore::Slots; slotIndex++)
|
for (int slotIndex = 0; slotIndex < MWWorld::InventoryStore::Slots; slotIndex++)
|
||||||
{
|
{
|
||||||
|
|
@ -306,82 +319,108 @@ namespace MWMechanics
|
||||||
// invisibility manually
|
// invisibility manually
|
||||||
purgeEffect(ptr, ESM::MagicEffect::Invisibility);
|
purgeEffect(ptr, ESM::MagicEffect::Invisibility);
|
||||||
applyPurges(ptr);
|
applyPurges(ptr);
|
||||||
ActiveSpellParams& params = mSpells.emplace_back(ActiveSpellParams{ *slot, enchantment, ptr });
|
ActiveSpellParams* params = initParams(ptr, ActiveSpellParams{ *slot, enchantment, ptr }, context);
|
||||||
params.setActiveSpellId(MWBase::Environment::get().getESMStore()->generateId());
|
if (params)
|
||||||
updateSpellWindow = true;
|
context.mUpdateSpellWindow = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const MWWorld::Ptr player = MWMechanics::getPlayer();
|
const MWWorld::Ptr player = MWMechanics::getPlayer();
|
||||||
bool updatedHitOverlay = false;
|
|
||||||
bool updatedEnemy = false;
|
|
||||||
// Update effects
|
// Update effects
|
||||||
|
context.mEraseRemoved = true;
|
||||||
for (auto spellIt = mSpells.begin(); spellIt != mSpells.end();)
|
for (auto spellIt = mSpells.begin(); spellIt != mSpells.end();)
|
||||||
{
|
{
|
||||||
const auto caster = MWBase::Environment::get().getWorld()->searchPtrViaActorId(
|
updateActiveSpell(ptr, duration, spellIt, context);
|
||||||
spellIt->mCasterActorId); // Maybe make this search outside active grid?
|
}
|
||||||
bool removedSpell = false;
|
|
||||||
std::optional<ActiveSpellParams> reflected;
|
|
||||||
for (auto it = spellIt->mEffects.begin(); it != spellIt->mEffects.end();)
|
|
||||||
{
|
|
||||||
auto result = applyMagicEffect(ptr, caster, *spellIt, *it, duration, playNonLooping);
|
|
||||||
if (result.mType == MagicApplicationResult::Type::REFLECTED)
|
|
||||||
{
|
|
||||||
if (!reflected)
|
|
||||||
{
|
|
||||||
if (Settings::game().mClassicReflectedAbsorbSpellsBehavior)
|
|
||||||
reflected = { *spellIt, caster };
|
|
||||||
else
|
|
||||||
reflected = { *spellIt, ptr };
|
|
||||||
}
|
|
||||||
auto& reflectedEffect = reflected->mEffects.emplace_back(*it);
|
|
||||||
reflectedEffect.mFlags
|
|
||||||
= ESM::ActiveEffect::Flag_Ignore_Reflect | ESM::ActiveEffect::Flag_Ignore_SpellAbsorption;
|
|
||||||
it = spellIt->mEffects.erase(it);
|
|
||||||
}
|
|
||||||
else if (result.mType == MagicApplicationResult::Type::REMOVED)
|
|
||||||
it = spellIt->mEffects.erase(it);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
++it;
|
|
||||||
if (!updatedEnemy && result.mShowHealth && caster == player && ptr != player)
|
|
||||||
{
|
|
||||||
MWBase::Environment::get().getWindowManager()->setEnemy(ptr);
|
|
||||||
updatedEnemy = true;
|
|
||||||
}
|
|
||||||
if (!updatedHitOverlay && result.mShowHit && ptr == player)
|
|
||||||
{
|
|
||||||
MWBase::Environment::get().getWindowManager()->activateHitOverlay(false);
|
|
||||||
updatedHitOverlay = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
removedSpell = applyPurges(ptr, &spellIt, &it);
|
|
||||||
if (removedSpell)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (reflected)
|
|
||||||
{
|
|
||||||
const ESM::Static* reflectStatic = MWBase::Environment::get().getESMStore()->get<ESM::Static>().find(
|
|
||||||
ESM::RefId::stringRefId("VFX_Reflect"));
|
|
||||||
MWRender::Animation* animation = MWBase::Environment::get().getWorld()->getAnimation(ptr);
|
|
||||||
if (animation && !reflectStatic->mModel.empty())
|
|
||||||
{
|
|
||||||
const VFS::Path::Normalized reflectStaticModel
|
|
||||||
= Misc::ResourceHelpers::correctMeshPath(VFS::Path::Normalized(reflectStatic->mModel));
|
|
||||||
animation->addEffect(
|
|
||||||
reflectStaticModel, ESM::MagicEffect::indexToName(ESM::MagicEffect::Reflect), false);
|
|
||||||
}
|
|
||||||
caster.getClass().getCreatureStats(caster).getActiveSpells().addSpell(*reflected);
|
|
||||||
}
|
|
||||||
if (removedSpell)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
|
if (Settings::game().mClassicCalmSpellsBehavior)
|
||||||
|
{
|
||||||
|
ESM::MagicEffect::Effects effect
|
||||||
|
= ptr.getClass().isNpc() ? ESM::MagicEffect::CalmHumanoid : ESM::MagicEffect::CalmCreature;
|
||||||
|
if (creatureStats.getMagicEffects().getOrDefault(effect).getMagnitude() > 0.f)
|
||||||
|
creatureStats.getAiSequence().stopCombat();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ptr == player && context.mUpdateSpellWindow)
|
||||||
|
{
|
||||||
|
// Something happened with the spell list -- possibly while the game is paused,
|
||||||
|
// so we want to make the spell window get the memo.
|
||||||
|
// We don't normally want to do this, so this targets constant enchantments.
|
||||||
|
MWBase::Environment::get().getWindowManager()->updateSpellWindow();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ActiveSpells::updateActiveSpell(
|
||||||
|
const MWWorld::Ptr& ptr, float duration, Collection::iterator& spellIt, UpdateContext& context)
|
||||||
|
{
|
||||||
|
const auto caster = MWBase::Environment::get().getWorld()->searchPtrViaActorId(
|
||||||
|
spellIt->mCasterActorId); // Maybe make this search outside active grid?
|
||||||
|
bool removedSpell = false;
|
||||||
|
std::optional<ActiveSpellParams> reflected;
|
||||||
|
for (auto it = spellIt->mEffects.begin(); it != spellIt->mEffects.end();)
|
||||||
|
{
|
||||||
|
auto result = applyMagicEffect(ptr, caster, *spellIt, *it, duration, context.mPlayNonLooping);
|
||||||
|
if (result.mType == MagicApplicationResult::Type::REFLECTED)
|
||||||
|
{
|
||||||
|
if (!reflected)
|
||||||
|
{
|
||||||
|
if (Settings::game().mClassicReflectedAbsorbSpellsBehavior)
|
||||||
|
reflected = { *spellIt, caster };
|
||||||
|
else
|
||||||
|
reflected = { *spellIt, ptr };
|
||||||
|
}
|
||||||
|
auto& reflectedEffect = reflected->mEffects.emplace_back(*it);
|
||||||
|
reflectedEffect.mFlags
|
||||||
|
= ESM::ActiveEffect::Flag_Ignore_Reflect | ESM::ActiveEffect::Flag_Ignore_SpellAbsorption;
|
||||||
|
it = spellIt->mEffects.erase(it);
|
||||||
|
}
|
||||||
|
else if (result.mType == MagicApplicationResult::Type::REMOVED)
|
||||||
|
it = spellIt->mEffects.erase(it);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const MWWorld::Ptr player = MWMechanics::getPlayer();
|
||||||
|
++it;
|
||||||
|
if (!context.mUpdatedEnemy && result.mShowHealth && caster == player && ptr != player)
|
||||||
|
{
|
||||||
|
MWBase::Environment::get().getWindowManager()->setEnemy(ptr);
|
||||||
|
context.mUpdatedEnemy = true;
|
||||||
|
}
|
||||||
|
if (!context.mUpdatedHitOverlay && result.mShowHit && ptr == player)
|
||||||
|
{
|
||||||
|
MWBase::Environment::get().getWindowManager()->activateHitOverlay(false);
|
||||||
|
context.mUpdatedHitOverlay = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
removedSpell = applyPurges(ptr, &spellIt, &it);
|
||||||
|
if (removedSpell)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (reflected)
|
||||||
|
{
|
||||||
|
const ESM::Static* reflectStatic = MWBase::Environment::get().getESMStore()->get<ESM::Static>().find(
|
||||||
|
ESM::RefId::stringRefId("VFX_Reflect"));
|
||||||
|
MWRender::Animation* animation = MWBase::Environment::get().getWorld()->getAnimation(ptr);
|
||||||
|
if (animation && !reflectStatic->mModel.empty())
|
||||||
|
{
|
||||||
|
const VFS::Path::Normalized reflectStaticModel
|
||||||
|
= Misc::ResourceHelpers::correctMeshPath(VFS::Path::Normalized(reflectStatic->mModel));
|
||||||
|
animation->addEffect(
|
||||||
|
reflectStaticModel, ESM::MagicEffect::indexToName(ESM::MagicEffect::Reflect), false);
|
||||||
|
}
|
||||||
|
caster.getClass().getCreatureStats(caster).getActiveSpells().addSpell(*reflected);
|
||||||
|
}
|
||||||
|
if (removedSpell)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (context.mEraseRemoved)
|
||||||
|
{
|
||||||
bool remove = false;
|
bool remove = false;
|
||||||
if (spellIt->hasFlag(ESM::ActiveSpells::Flag_SpellStore))
|
if (spellIt->hasFlag(ESM::ActiveSpells::Flag_SpellStore))
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
auto& spells = ptr.getClass().getCreatureStats(ptr).getSpells();
|
||||||
remove = !spells.hasSpell(spellIt->mSourceSpellId);
|
remove = !spells.hasSpell(spellIt->mSourceSpellId);
|
||||||
}
|
}
|
||||||
catch (const std::runtime_error& e)
|
catch (const std::runtime_error& e)
|
||||||
|
|
@ -413,30 +452,27 @@ namespace MWMechanics
|
||||||
for (const auto& effect : params.mEffects)
|
for (const auto& effect : params.mEffects)
|
||||||
onMagicEffectRemoved(ptr, params, effect);
|
onMagicEffectRemoved(ptr, params, effect);
|
||||||
applyPurges(ptr, &spellIt);
|
applyPurges(ptr, &spellIt);
|
||||||
updateSpellWindow = true;
|
context.mUpdateSpellWindow = true;
|
||||||
continue;
|
return true;
|
||||||
}
|
}
|
||||||
++spellIt;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Settings::game().mClassicCalmSpellsBehavior)
|
|
||||||
{
|
|
||||||
ESM::MagicEffect::Effects effect
|
|
||||||
= ptr.getClass().isNpc() ? ESM::MagicEffect::CalmHumanoid : ESM::MagicEffect::CalmCreature;
|
|
||||||
if (creatureStats.getMagicEffects().getOrDefault(effect).getMagnitude() > 0.f)
|
|
||||||
creatureStats.getAiSequence().stopCombat();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ptr == player && updateSpellWindow)
|
|
||||||
{
|
|
||||||
// Something happened with the spell list -- possibly while the game is paused,
|
|
||||||
// so we want to make the spell window get the memo.
|
|
||||||
// We don't normally want to do this, so this targets constant enchantments.
|
|
||||||
MWBase::Environment::get().getWindowManager()->updateSpellWindow();
|
|
||||||
}
|
}
|
||||||
|
++spellIt;
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActiveSpells::addToSpells(const MWWorld::Ptr& ptr, const ActiveSpellParams& spell)
|
ActiveSpells::ActiveSpellParams* ActiveSpells::initParams(
|
||||||
|
const MWWorld::Ptr& ptr, const ActiveSpellParams& params, UpdateContext& context)
|
||||||
|
{
|
||||||
|
mSpells.emplace_back(params).setActiveSpellId(MWBase::Environment::get().getESMStore()->generateId());
|
||||||
|
auto it = mSpells.end();
|
||||||
|
--it;
|
||||||
|
// We instantly apply the effect with a duration of 0 so continuous effects can be purged before truly applying
|
||||||
|
if (context.mUpdate && updateActiveSpell(ptr, 0.f, it, context))
|
||||||
|
return nullptr;
|
||||||
|
return &*it;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ActiveSpells::addToSpells(const MWWorld::Ptr& ptr, const ActiveSpellParams& spell, UpdateContext& context)
|
||||||
{
|
{
|
||||||
if (!spell.hasFlag(ESM::ActiveSpells::Flag_Stackable))
|
if (!spell.hasFlag(ESM::ActiveSpells::Flag_Stackable))
|
||||||
{
|
{
|
||||||
|
|
@ -454,8 +490,7 @@ namespace MWMechanics
|
||||||
onMagicEffectRemoved(ptr, params, effect);
|
onMagicEffectRemoved(ptr, params, effect);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mSpells.emplace_back(spell);
|
initParams(ptr, spell, context);
|
||||||
mSpells.back().setActiveSpellId(MWBase::Environment::get().getESMStore()->generateId());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ActiveSpells::ActiveSpells()
|
ActiveSpells::ActiveSpells()
|
||||||
|
|
@ -608,6 +643,8 @@ namespace MWMechanics
|
||||||
{
|
{
|
||||||
purge(
|
purge(
|
||||||
[=](const ActiveSpellParams&, const ESM::ActiveEffect& effect) {
|
[=](const ActiveSpellParams&, const ESM::ActiveEffect& effect) {
|
||||||
|
if (!(effect.mFlags & ESM::ActiveEffect::Flag_Applied))
|
||||||
|
return false;
|
||||||
if (effectArg.empty())
|
if (effectArg.empty())
|
||||||
return effect.mEffectId == effectId;
|
return effect.mEffectId == effectId;
|
||||||
return effect.mEffectId == effectId && effect.getSkillOrAttribute() == effectArg;
|
return effect.mEffectId == effectId && effect.getSkillOrAttribute() == effectArg;
|
||||||
|
|
|
||||||
|
|
@ -116,17 +116,23 @@ namespace MWMechanics
|
||||||
IterationGuard(ActiveSpells& spells);
|
IterationGuard(ActiveSpells& spells);
|
||||||
~IterationGuard();
|
~IterationGuard();
|
||||||
};
|
};
|
||||||
|
struct UpdateContext;
|
||||||
|
|
||||||
std::list<ActiveSpellParams> mSpells;
|
std::list<ActiveSpellParams> mSpells;
|
||||||
std::vector<ActiveSpellParams> mQueue;
|
std::vector<ActiveSpellParams> mQueue;
|
||||||
std::queue<Predicate> mPurges;
|
std::queue<Predicate> mPurges;
|
||||||
bool mIterating;
|
bool mIterating;
|
||||||
|
|
||||||
void addToSpells(const MWWorld::Ptr& ptr, const ActiveSpellParams& spell);
|
void addToSpells(const MWWorld::Ptr& ptr, const ActiveSpellParams& spell, UpdateContext& context);
|
||||||
|
|
||||||
bool applyPurges(const MWWorld::Ptr& ptr, std::list<ActiveSpellParams>::iterator* currentSpell = nullptr,
|
bool applyPurges(const MWWorld::Ptr& ptr, std::list<ActiveSpellParams>::iterator* currentSpell = nullptr,
|
||||||
std::vector<ActiveEffect>::iterator* currentEffect = nullptr);
|
std::vector<ActiveEffect>::iterator* currentEffect = nullptr);
|
||||||
|
|
||||||
|
bool updateActiveSpell(
|
||||||
|
const MWWorld::Ptr& ptr, float duration, Collection::iterator& spellIt, UpdateContext& context);
|
||||||
|
|
||||||
|
ActiveSpellParams* initParams(const MWWorld::Ptr& ptr, const ActiveSpellParams& params, UpdateContext& context);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ActiveSpells();
|
ActiveSpells();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1326,19 +1326,37 @@ namespace MWMechanics
|
||||||
|
|
||||||
const MWWorld::Ptr player = getPlayer();
|
const MWWorld::Ptr player = getPlayer();
|
||||||
const MWBase::World* const world = MWBase::Environment::get().getWorld();
|
const MWBase::World* const world = MWBase::Environment::get().getWorld();
|
||||||
|
|
||||||
|
struct CacheEntry
|
||||||
|
{
|
||||||
|
MWWorld::Ptr mPtr;
|
||||||
|
float mMaxSpeed;
|
||||||
|
osg::Vec3f mHalfExtents;
|
||||||
|
Movement& mMovement;
|
||||||
|
};
|
||||||
|
|
||||||
|
std::vector<CacheEntry> cache;
|
||||||
|
cache.reserve(mActors.size());
|
||||||
for (const Actor& actor : mActors)
|
for (const Actor& actor : mActors)
|
||||||
{
|
{
|
||||||
if (actor.isInvalid())
|
if (actor.isInvalid())
|
||||||
continue;
|
continue;
|
||||||
const MWWorld::Ptr& ptr = actor.getPtr();
|
const MWWorld::Ptr& ptr = actor.getPtr();
|
||||||
|
const MWWorld::Class& cls = ptr.getClass();
|
||||||
|
cache.push_back({ ptr, cls.getMaxSpeed(ptr), world->getHalfExtents(ptr), cls.getMovementSettings(ptr) });
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const CacheEntry& cached : cache)
|
||||||
|
{
|
||||||
|
const MWWorld::Ptr& ptr = cached.mPtr;
|
||||||
if (ptr == player)
|
if (ptr == player)
|
||||||
continue; // Don't interfere with player controls.
|
continue; // Don't interfere with player controls.
|
||||||
|
|
||||||
const float maxSpeed = ptr.getClass().getMaxSpeed(ptr);
|
const float maxSpeed = cached.mMaxSpeed;
|
||||||
if (maxSpeed == 0.0)
|
if (maxSpeed == 0.0)
|
||||||
continue; // Can't move, so there is no sense to predict collisions.
|
continue; // Can't move, so there is no sense to predict collisions.
|
||||||
|
|
||||||
Movement& movement = ptr.getClass().getMovementSettings(ptr);
|
Movement& movement = cached.mMovement;
|
||||||
const osg::Vec2f origMovement(movement.mPosition[0], movement.mPosition[1]);
|
const osg::Vec2f origMovement(movement.mPosition[0], movement.mPosition[1]);
|
||||||
const bool isMoving = origMovement.length2() > 0.01;
|
const bool isMoving = origMovement.length2() > 0.01;
|
||||||
if (movement.mPosition[1] < 0)
|
if (movement.mPosition[1] < 0)
|
||||||
|
|
@ -1379,7 +1397,7 @@ namespace MWMechanics
|
||||||
const osg::Vec2f baseSpeed = origMovement * maxSpeed;
|
const osg::Vec2f baseSpeed = origMovement * maxSpeed;
|
||||||
const osg::Vec3f basePos = ptr.getRefData().getPosition().asVec3();
|
const osg::Vec3f basePos = ptr.getRefData().getPosition().asVec3();
|
||||||
const float baseRotZ = ptr.getRefData().getPosition().rot[2];
|
const float baseRotZ = ptr.getRefData().getPosition().rot[2];
|
||||||
const osg::Vec3f halfExtents = world->getHalfExtents(ptr);
|
const osg::Vec3f& halfExtents = cached.mHalfExtents;
|
||||||
const float maxDistToCheck = isMoving ? maxDistForPartialAvoiding : maxDistForStrictAvoiding;
|
const float maxDistToCheck = isMoving ? maxDistForPartialAvoiding : maxDistForStrictAvoiding;
|
||||||
|
|
||||||
float timeToCheck = maxTimeToCheck;
|
float timeToCheck = maxTimeToCheck;
|
||||||
|
|
@ -1392,15 +1410,13 @@ namespace MWMechanics
|
||||||
float angleToApproachingActor = 0;
|
float angleToApproachingActor = 0;
|
||||||
|
|
||||||
// Iterate through all other actors and predict collisions.
|
// Iterate through all other actors and predict collisions.
|
||||||
for (const Actor& otherActor : mActors)
|
for (const CacheEntry& otherCached : cache)
|
||||||
{
|
{
|
||||||
if (otherActor.isInvalid())
|
const MWWorld::Ptr& otherPtr = otherCached.mPtr;
|
||||||
continue;
|
|
||||||
const MWWorld::Ptr& otherPtr = otherActor.getPtr();
|
|
||||||
if (otherPtr == ptr || otherPtr == currentTarget)
|
if (otherPtr == ptr || otherPtr == currentTarget)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
const osg::Vec3f otherHalfExtents = world->getHalfExtents(otherPtr);
|
const osg::Vec3f& otherHalfExtents = otherCached.mHalfExtents;
|
||||||
const osg::Vec3f deltaPos = otherPtr.getRefData().getPosition().asVec3() - basePos;
|
const osg::Vec3f deltaPos = otherPtr.getRefData().getPosition().asVec3() - basePos;
|
||||||
const osg::Vec2f relPos = Misc::rotateVec2f(osg::Vec2f(deltaPos.x(), deltaPos.y()), baseRotZ);
|
const osg::Vec2f relPos = Misc::rotateVec2f(osg::Vec2f(deltaPos.x(), deltaPos.y()), baseRotZ);
|
||||||
const float dist = deltaPos.length();
|
const float dist = deltaPos.length();
|
||||||
|
|
@ -1413,8 +1429,7 @@ namespace MWMechanics
|
||||||
if (deltaPos.z() > halfExtents.z() * 2 || deltaPos.z() < -otherHalfExtents.z() * 2)
|
if (deltaPos.z() > halfExtents.z() * 2 || deltaPos.z() < -otherHalfExtents.z() * 2)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
const osg::Vec3f speed = otherPtr.getClass().getMovementSettings(otherPtr).asVec3()
|
const osg::Vec3f speed = otherCached.mMovement.asVec3() * otherCached.mMaxSpeed;
|
||||||
* otherPtr.getClass().getMaxSpeed(otherPtr);
|
|
||||||
const float rotZ = otherPtr.getRefData().getPosition().rot[2];
|
const float rotZ = otherPtr.getRefData().getPosition().rot[2];
|
||||||
const osg::Vec2f relSpeed
|
const osg::Vec2f relSpeed
|
||||||
= Misc::rotateVec2f(osg::Vec2f(speed.x(), speed.y()), baseRotZ - rotZ) - baseSpeed;
|
= Misc::rotateVec2f(osg::Vec2f(speed.x(), speed.y()), baseRotZ - rotZ) - baseSpeed;
|
||||||
|
|
|
||||||
|
|
@ -178,11 +178,16 @@ namespace MWMechanics
|
||||||
currentCell = actor.getCell();
|
currentCell = actor.getCell();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const MWWorld::Class& actorClass = actor.getClass();
|
||||||
|
MWMechanics::CreatureStats& stats = actorClass.getCreatureStats(actor);
|
||||||
|
if (stats.isParalyzed() || stats.getKnockedDown())
|
||||||
|
return false;
|
||||||
|
|
||||||
bool forceFlee = false;
|
bool forceFlee = false;
|
||||||
if (!canFight(actor, target))
|
if (!canFight(actor, target))
|
||||||
{
|
{
|
||||||
storage.stopAttack();
|
storage.stopAttack();
|
||||||
actor.getClass().getCreatureStats(actor).setAttackingOrSpell(false);
|
stats.setAttackingOrSpell(false);
|
||||||
storage.mActionCooldown = 0.f;
|
storage.mActionCooldown = 0.f;
|
||||||
// Continue combat if target is player or player follower/escorter and an attack has been attempted
|
// Continue combat if target is player or player follower/escorter and an attack has been attempted
|
||||||
const auto& playerFollowersAndEscorters
|
const auto& playerFollowersAndEscorters
|
||||||
|
|
@ -191,18 +196,14 @@ namespace MWMechanics
|
||||||
= (std::find(playerFollowersAndEscorters.begin(), playerFollowersAndEscorters.end(), target)
|
= (std::find(playerFollowersAndEscorters.begin(), playerFollowersAndEscorters.end(), target)
|
||||||
!= playerFollowersAndEscorters.end());
|
!= playerFollowersAndEscorters.end());
|
||||||
if ((target == MWMechanics::getPlayer() || targetSidesWithPlayer)
|
if ((target == MWMechanics::getPlayer() || targetSidesWithPlayer)
|
||||||
&& ((actor.getClass().getCreatureStats(actor).getHitAttemptActorId()
|
&& ((stats.getHitAttemptActorId() == target.getClass().getCreatureStats(target).getActorId())
|
||||||
== target.getClass().getCreatureStats(target).getActorId())
|
|| (target.getClass().getCreatureStats(target).getHitAttemptActorId() == stats.getActorId())))
|
||||||
|| (target.getClass().getCreatureStats(target).getHitAttemptActorId()
|
|
||||||
== actor.getClass().getCreatureStats(actor).getActorId())))
|
|
||||||
forceFlee = true;
|
forceFlee = true;
|
||||||
else // Otherwise end combat
|
else // Otherwise end combat
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const MWWorld::Class& actorClass = actor.getClass();
|
stats.setMovementFlag(CreatureStats::Flag_Run, true);
|
||||||
actorClass.getCreatureStats(actor).setMovementFlag(CreatureStats::Flag_Run, true);
|
|
||||||
|
|
||||||
float& actionCooldown = storage.mActionCooldown;
|
float& actionCooldown = storage.mActionCooldown;
|
||||||
std::unique_ptr<Action>& currentAction = storage.mCurrentAction;
|
std::unique_ptr<Action>& currentAction = storage.mCurrentAction;
|
||||||
|
|
||||||
|
|
@ -330,7 +331,7 @@ namespace MWMechanics
|
||||||
{
|
{
|
||||||
storage.mUseCustomDestination = false;
|
storage.mUseCustomDestination = false;
|
||||||
storage.stopAttack();
|
storage.stopAttack();
|
||||||
actor.getClass().getCreatureStats(actor).setAttackingOrSpell(false);
|
stats.setAttackingOrSpell(false);
|
||||||
currentAction = std::make_unique<ActionFlee>();
|
currentAction = std::make_unique<ActionFlee>();
|
||||||
actionCooldown = currentAction->getActionCooldown();
|
actionCooldown = currentAction->getActionCooldown();
|
||||||
storage.startFleeing();
|
storage.startFleeing();
|
||||||
|
|
|
||||||
|
|
@ -2310,17 +2310,13 @@ namespace MWMechanics
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Do not play turning animation for player if rotation speed is very slow.
|
|
||||||
// Actual threshold should take framerate in account.
|
|
||||||
float rotationThreshold = (isPlayer ? 0.015f : 0.001f) * 60 * duration;
|
|
||||||
|
|
||||||
// It seems only bipedal actors use turning animations.
|
// It seems only bipedal actors use turning animations.
|
||||||
// Also do not use turning animations in the first-person view and when sneaking.
|
// Also do not use turning animations in the first-person view and when sneaking.
|
||||||
if (!sneak && !isFirstPersonPlayer && isBiped)
|
if (!sneak && !isFirstPersonPlayer && isBiped)
|
||||||
{
|
{
|
||||||
if (effectiveRotation > rotationThreshold)
|
if (effectiveRotation > 0.f)
|
||||||
movestate = inwater ? CharState_SwimTurnRight : CharState_TurnRight;
|
movestate = inwater ? CharState_SwimTurnRight : CharState_TurnRight;
|
||||||
else if (effectiveRotation < -rotationThreshold)
|
else if (effectiveRotation < 0.f)
|
||||||
movestate = inwater ? CharState_SwimTurnLeft : CharState_TurnLeft;
|
movestate = inwater ? CharState_SwimTurnLeft : CharState_TurnLeft;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -2346,34 +2342,19 @@ namespace MWMechanics
|
||||||
vec.y() *= std::sqrt(1.0f - swimUpwardCoef * swimUpwardCoef);
|
vec.y() *= std::sqrt(1.0f - swimUpwardCoef * swimUpwardCoef);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Player can not use smooth turning as NPCs, so we play turning animation a bit to avoid jittering
|
if (isBiped)
|
||||||
if (isPlayer)
|
|
||||||
{
|
{
|
||||||
float threshold = mCurrentMovement.find("swim") == std::string::npos ? 0.4f : 0.8f;
|
if (mTurnAnimationThreshold > 0)
|
||||||
float complete;
|
mTurnAnimationThreshold -= duration;
|
||||||
bool animPlaying = mAnimation->getInfo(mCurrentMovement, &complete);
|
|
||||||
if (movestate == CharState_None && jumpstate == JumpState_None && isTurning())
|
|
||||||
{
|
|
||||||
if (animPlaying && complete < threshold)
|
|
||||||
movestate = mMovementState;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (isBiped)
|
|
||||||
{
|
|
||||||
if (mTurnAnimationThreshold > 0)
|
|
||||||
mTurnAnimationThreshold -= duration;
|
|
||||||
|
|
||||||
if (movestate == CharState_TurnRight || movestate == CharState_TurnLeft
|
if (movestate == CharState_TurnRight || movestate == CharState_TurnLeft
|
||||||
|| movestate == CharState_SwimTurnRight || movestate == CharState_SwimTurnLeft)
|
|| movestate == CharState_SwimTurnRight || movestate == CharState_SwimTurnLeft)
|
||||||
{
|
{
|
||||||
mTurnAnimationThreshold = 0.05f;
|
mTurnAnimationThreshold = 0.05f;
|
||||||
}
|
}
|
||||||
else if (movestate == CharState_None && isTurning() && mTurnAnimationThreshold > 0)
|
else if (movestate == CharState_None && isTurning() && mTurnAnimationThreshold > 0)
|
||||||
{
|
{
|
||||||
movestate = mMovementState;
|
movestate = mMovementState;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2402,11 +2383,10 @@ namespace MWMechanics
|
||||||
|
|
||||||
if (isTurning())
|
if (isTurning())
|
||||||
{
|
{
|
||||||
// Adjust animation speed from 1.0 to 1.5 multiplier
|
|
||||||
if (duration > 0)
|
if (duration > 0)
|
||||||
{
|
{
|
||||||
float turnSpeed = std::min(1.5f, std::abs(rot.z()) / duration / static_cast<float>(osg::PI));
|
float turnSpeed = std::min(1.5f, std::abs(rot.z()) / duration / static_cast<float>(osg::PI));
|
||||||
mAnimation->adjustSpeedMult(mCurrentMovement, std::max(turnSpeed, 1.0f));
|
mAnimation->adjustSpeedMult(mCurrentMovement, turnSpeed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (mMovementState != CharState_None && mAdjustMovementAnimSpeed)
|
else if (mMovementState != CharState_None && mAdjustMovementAnimSpeed)
|
||||||
|
|
|
||||||
|
|
@ -215,10 +215,6 @@ namespace MWMechanics
|
||||||
bool hasDuration = !(magicEffect->mData.mFlags & ESM::MagicEffect::NoDuration);
|
bool hasDuration = !(magicEffect->mData.mFlags & ESM::MagicEffect::NoDuration);
|
||||||
effect.mDuration = hasDuration ? static_cast<float>(enam.mData.mDuration) : 1.f;
|
effect.mDuration = hasDuration ? static_cast<float>(enam.mData.mDuration) : 1.f;
|
||||||
|
|
||||||
bool appliedOnce = magicEffect->mData.mFlags & ESM::MagicEffect::AppliedOnce;
|
|
||||||
if (!appliedOnce)
|
|
||||||
effect.mDuration = std::max(1.f, effect.mDuration);
|
|
||||||
|
|
||||||
effect.mTimeLeft = effect.mDuration;
|
effect.mTimeLeft = effect.mDuration;
|
||||||
|
|
||||||
// add to list of active effects, to apply in next frame
|
// add to list of active effects, to apply in next frame
|
||||||
|
|
|
||||||
|
|
@ -1011,11 +1011,13 @@ namespace MWMechanics
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Morrowind.exe doesn't apply magic effects while the menu is open, we do because we like to see stats
|
// Morrowind.exe doesn't apply magic effects while the menu is open, we do because we like to see stats
|
||||||
// updated instantly. We don't want to teleport instantly though
|
// updated instantly. We don't want to teleport instantly though. Nor do we want to force players to drink
|
||||||
|
// invisibility potions in the "right" order
|
||||||
if (!dt
|
if (!dt
|
||||||
&& (effect.mEffectId == ESM::MagicEffect::Recall
|
&& (effect.mEffectId == ESM::MagicEffect::Recall
|
||||||
|| effect.mEffectId == ESM::MagicEffect::DivineIntervention
|
|| effect.mEffectId == ESM::MagicEffect::DivineIntervention
|
||||||
|| effect.mEffectId == ESM::MagicEffect::AlmsiviIntervention))
|
|| effect.mEffectId == ESM::MagicEffect::AlmsiviIntervention
|
||||||
|
|| effect.mEffectId == ESM::MagicEffect::Invisibility))
|
||||||
return { MagicApplicationResult::Type::APPLIED, receivedMagicDamage, affectedHealth };
|
return { MagicApplicationResult::Type::APPLIED, receivedMagicDamage, affectedHealth };
|
||||||
auto& stats = target.getClass().getCreatureStats(target);
|
auto& stats = target.getClass().getCreatureStats(target);
|
||||||
auto& magnitudes = stats.getMagicEffects();
|
auto& magnitudes = stats.getMagicEffects();
|
||||||
|
|
|
||||||
|
|
@ -943,8 +943,8 @@ namespace MWRender
|
||||||
stateUpdater->setIsUnderwater(isUnderwater);
|
stateUpdater->setIsUnderwater(isUnderwater);
|
||||||
stateUpdater->setFogColor(fogColor);
|
stateUpdater->setFogColor(fogColor);
|
||||||
stateUpdater->setGameHour(world->getTimeStamp().getHour());
|
stateUpdater->setGameHour(world->getTimeStamp().getHour());
|
||||||
stateUpdater->setWeatherId(world->getCurrentWeather());
|
stateUpdater->setWeatherId(world->getCurrentWeatherScriptId());
|
||||||
stateUpdater->setNextWeatherId(world->getNextWeather());
|
stateUpdater->setNextWeatherId(world->getNextWeatherScriptId());
|
||||||
stateUpdater->setWeatherTransition(world->getWeatherTransition());
|
stateUpdater->setWeatherTransition(world->getWeatherTransition());
|
||||||
stateUpdater->setWindSpeed(world->getWindSpeed());
|
stateUpdater->setWindSpeed(world->getWindSpeed());
|
||||||
stateUpdater->setSkyColor(mSky->getSkyColor());
|
stateUpdater->setSkyColor(mSky->getSkyColor());
|
||||||
|
|
|
||||||
|
|
@ -139,6 +139,7 @@ namespace MWRender
|
||||||
int skyGetSecundaPhase() const;
|
int skyGetSecundaPhase() const;
|
||||||
void skySetMoonColour(bool red);
|
void skySetMoonColour(bool red);
|
||||||
|
|
||||||
|
const osg::Vec4f& getSunLightPosition() const { return mSunLight->getPosition(); }
|
||||||
void setSunDirection(const osg::Vec3f& direction);
|
void setSunDirection(const osg::Vec3f& direction);
|
||||||
void setSunColour(const osg::Vec4f& diffuse, const osg::Vec4f& specular, float sunVis);
|
void setSunColour(const osg::Vec4f& diffuse, const osg::Vec4f& specular, float sunVis);
|
||||||
void setNight(bool isNight) { mNight = isNight; }
|
void setNight(bool isNight) { mNight = isNight; }
|
||||||
|
|
|
||||||
|
|
@ -71,7 +71,7 @@ namespace MWScript
|
||||||
public:
|
public:
|
||||||
void execute(Interpreter::Runtime& runtime) override
|
void execute(Interpreter::Runtime& runtime) override
|
||||||
{
|
{
|
||||||
runtime.push(MWBase::Environment::get().getWorld()->getCurrentWeather());
|
runtime.push(MWBase::Environment::get().getWorld()->getCurrentWeatherScriptId());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
#include "weather.hpp"
|
#include "weather.hpp"
|
||||||
|
|
||||||
|
#include <components/esm/stringrefid.hpp>
|
||||||
#include <components/settings/values.hpp>
|
#include <components/settings/values.hpp>
|
||||||
|
|
||||||
#include <components/misc/rng.hpp>
|
#include <components/misc/rng.hpp>
|
||||||
|
|
@ -141,9 +142,12 @@ namespace MWWorld
|
||||||
return direction;
|
return direction;
|
||||||
}
|
}
|
||||||
|
|
||||||
Weather::Weather(const std::string& name, float stormWindSpeed, float rainSpeed, float dlFactor, float dlOffset,
|
Weather::Weather(ESM::RefId id, int scriptId, const std::string& name, float stormWindSpeed, float rainSpeed,
|
||||||
const std::string& particleEffect)
|
float dlFactor, float dlOffset, const std::string& particleEffect)
|
||||||
: mCloudTexture(Fallback::Map::getString("Weather_" + name + "_Cloud_Texture"))
|
: mId(id)
|
||||||
|
, mScriptId(scriptId)
|
||||||
|
, mName(name)
|
||||||
|
, mCloudTexture(Fallback::Map::getString("Weather_" + name + "_Cloud_Texture"))
|
||||||
, mSkyColor(Fallback::Map::getColour("Weather_" + name + "_Sky_Sunrise_Color"),
|
, mSkyColor(Fallback::Map::getColour("Weather_" + name + "_Sky_Sunrise_Color"),
|
||||||
Fallback::Map::getColour("Weather_" + name + "_Sky_Day_Color"),
|
Fallback::Map::getColour("Weather_" + name + "_Sky_Day_Color"),
|
||||||
Fallback::Map::getColour("Weather_" + name + "_Sky_Sunset_Color"),
|
Fallback::Map::getColour("Weather_" + name + "_Sky_Sunset_Color"),
|
||||||
|
|
@ -676,6 +680,41 @@ namespace MWWorld
|
||||||
stopSounds();
|
stopSounds();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const Weather* WeatherManager::getWeather(size_t index) const
|
||||||
|
{
|
||||||
|
if (index < mWeatherSettings.size())
|
||||||
|
return &mWeatherSettings[index];
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
const Weather* WeatherManager::getWeather(const ESM::RefId& id) const
|
||||||
|
{
|
||||||
|
auto it = std::find_if(
|
||||||
|
mWeatherSettings.begin(), mWeatherSettings.end(), [id](const auto& weather) { return weather.mId == id; });
|
||||||
|
|
||||||
|
if (it != mWeatherSettings.end())
|
||||||
|
return &*it;
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void WeatherManager::changeWeather(const ESM::RefId& regionID, const ESM::RefId& weatherID)
|
||||||
|
{
|
||||||
|
auto wIt = std::find_if(mWeatherSettings.begin(), mWeatherSettings.end(),
|
||||||
|
[weatherID](const auto& weather) { return weather.mId == weatherID; });
|
||||||
|
|
||||||
|
if (wIt != mWeatherSettings.end())
|
||||||
|
{
|
||||||
|
auto rIt = mRegions.find(regionID);
|
||||||
|
if (rIt != mRegions.end())
|
||||||
|
{
|
||||||
|
rIt->second.setWeather(std::distance(mWeatherSettings.begin(), wIt));
|
||||||
|
regionalWeatherChanged(rIt->first, rIt->second);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void WeatherManager::changeWeather(const ESM::RefId& regionID, const unsigned int weatherID)
|
void WeatherManager::changeWeather(const ESM::RefId& regionID, const unsigned int weatherID)
|
||||||
{
|
{
|
||||||
// In Morrowind, this seems to have the following behavior, when applied to the current region:
|
// In Morrowind, this seems to have the following behavior, when applied to the current region:
|
||||||
|
|
@ -1053,8 +1092,9 @@ namespace MWWorld
|
||||||
const std::string& name, float dlFactor, float dlOffset, const std::string& particleEffect)
|
const std::string& name, float dlFactor, float dlOffset, const std::string& particleEffect)
|
||||||
{
|
{
|
||||||
static const float fStromWindSpeed = mStore.get<ESM::GameSetting>().find("fStromWindSpeed")->mValue.getFloat();
|
static const float fStromWindSpeed = mStore.get<ESM::GameSetting>().find("fStromWindSpeed")->mValue.getFloat();
|
||||||
|
ESM::StringRefId id(name);
|
||||||
Weather weather(name, fStromWindSpeed, mRainSpeed, dlFactor, dlOffset, particleEffect);
|
Weather weather(
|
||||||
|
id, mWeatherSettings.size(), name, fStromWindSpeed, mRainSpeed, dlFactor, dlOffset, particleEffect);
|
||||||
|
|
||||||
mWeatherSettings.push_back(weather);
|
mWeatherSettings.push_back(weather);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -109,6 +109,11 @@ namespace MWWorld
|
||||||
|
|
||||||
T getValue(const float gameHour, const TimeOfDaySettings& timeSettings, const std::string& prefix) const;
|
T getValue(const float gameHour, const TimeOfDaySettings& timeSettings, const std::string& prefix) const;
|
||||||
|
|
||||||
|
const T& getSunriseValue() const { return mSunriseValue; }
|
||||||
|
const T& getDayValue() const { return mDayValue; }
|
||||||
|
const T& getSunsetValue() const { return mSunsetValue; }
|
||||||
|
const T& getNightValue() const { return mNightValue; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
T mSunriseValue, mDayValue, mSunsetValue, mNightValue;
|
T mSunriseValue, mDayValue, mSunsetValue, mNightValue;
|
||||||
};
|
};
|
||||||
|
|
@ -119,9 +124,12 @@ namespace MWWorld
|
||||||
public:
|
public:
|
||||||
static osg::Vec3f defaultDirection();
|
static osg::Vec3f defaultDirection();
|
||||||
|
|
||||||
Weather(const std::string& name, float stormWindSpeed, float rainSpeed, float dlFactor, float dlOffset,
|
Weather(const ESM::RefId id, const int scriptId, const std::string& name, float stormWindSpeed, float rainSpeed,
|
||||||
const std::string& particleEffect);
|
float dlFactor, float dlOffset, const std::string& particleEffect);
|
||||||
|
|
||||||
|
ESM::RefId mId;
|
||||||
|
int mScriptId;
|
||||||
|
std::string mName;
|
||||||
std::string mCloudTexture;
|
std::string mCloudTexture;
|
||||||
|
|
||||||
// Sky (atmosphere) color
|
// Sky (atmosphere) color
|
||||||
|
|
@ -289,11 +297,12 @@ namespace MWWorld
|
||||||
~WeatherManager();
|
~WeatherManager();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Change the weather in the specified region
|
* Change the weather in the specified region by id of the weather
|
||||||
* @param region that should be changed
|
* @param region that should be changed
|
||||||
* @param ID of the weather setting to shift to
|
* @param ID of the weather setting to shift to
|
||||||
*/
|
*/
|
||||||
void changeWeather(const ESM::RefId& regionID, const unsigned int weatherID);
|
void changeWeather(const ESM::RefId& regionID, const unsigned int weatherID);
|
||||||
|
void changeWeather(const ESM::RefId& regionID, const ESM::RefId& weatherID);
|
||||||
void modRegion(const ESM::RefId& regionID, const std::vector<uint8_t>& chances);
|
void modRegion(const ESM::RefId& regionID, const std::vector<uint8_t>& chances);
|
||||||
void playerTeleported(const ESM::RefId& playerRegion, bool isExterior);
|
void playerTeleported(const ESM::RefId& playerRegion, bool isExterior);
|
||||||
|
|
||||||
|
|
@ -316,8 +325,23 @@ namespace MWWorld
|
||||||
|
|
||||||
void advanceTime(double hours, bool incremental);
|
void advanceTime(double hours, bool incremental);
|
||||||
|
|
||||||
|
const std::vector<Weather>& getAllWeather() { return mWeatherSettings; }
|
||||||
|
|
||||||
|
const Weather& getWeather() { return mWeatherSettings[mCurrentWeather]; }
|
||||||
|
|
||||||
|
const Weather* getWeather(size_t index) const;
|
||||||
|
|
||||||
|
const Weather* getWeather(const ESM::RefId& id) const;
|
||||||
|
|
||||||
int getWeatherID() const { return mCurrentWeather; }
|
int getWeatherID() const { return mCurrentWeather; }
|
||||||
|
|
||||||
|
const Weather* getNextWeather()
|
||||||
|
{
|
||||||
|
if (mNextWeather > -1)
|
||||||
|
return &mWeatherSettings[mNextWeather];
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
int getNextWeatherID() const { return mNextWeather; }
|
int getNextWeatherID() const { return mNextWeather; }
|
||||||
|
|
||||||
float getTransitionFactor() const { return mTransitionFactor; }
|
float getTransitionFactor() const { return mTransitionFactor; }
|
||||||
|
|
|
||||||
|
|
@ -1868,14 +1868,43 @@ namespace MWWorld
|
||||||
return ESM::Cell::sDefaultWorldspaceId;
|
return ESM::Cell::sDefaultWorldspaceId;
|
||||||
}
|
}
|
||||||
|
|
||||||
int World::getCurrentWeather() const
|
const std::vector<MWWorld::Weather>& World::getAllWeather() const
|
||||||
{
|
{
|
||||||
return mWeatherManager->getWeatherID();
|
return mWeatherManager->getAllWeather();
|
||||||
}
|
}
|
||||||
|
|
||||||
int World::getNextWeather() const
|
int World::getCurrentWeatherScriptId() const
|
||||||
{
|
{
|
||||||
return mWeatherManager->getNextWeatherID();
|
return mWeatherManager->getWeather().mScriptId;
|
||||||
|
}
|
||||||
|
|
||||||
|
const MWWorld::Weather& World::getCurrentWeather() const
|
||||||
|
{
|
||||||
|
return mWeatherManager->getWeather();
|
||||||
|
}
|
||||||
|
|
||||||
|
const MWWorld::Weather* World::getWeather(size_t index) const
|
||||||
|
{
|
||||||
|
return mWeatherManager->getWeather(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
const MWWorld::Weather* World::getWeather(const ESM::RefId& id) const
|
||||||
|
{
|
||||||
|
return mWeatherManager->getWeather(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
int World::getNextWeatherScriptId() const
|
||||||
|
{
|
||||||
|
auto next = mWeatherManager->getNextWeather();
|
||||||
|
if (next == nullptr)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
return next->mScriptId;
|
||||||
|
}
|
||||||
|
|
||||||
|
const MWWorld::Weather* World::getNextWeather() const
|
||||||
|
{
|
||||||
|
return mWeatherManager->getNextWeather();
|
||||||
}
|
}
|
||||||
|
|
||||||
float World::getWeatherTransition() const
|
float World::getWeatherTransition() const
|
||||||
|
|
@ -1893,6 +1922,11 @@ namespace MWWorld
|
||||||
mWeatherManager->changeWeather(region, id);
|
mWeatherManager->changeWeather(region, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void World::changeWeather(const ESM::RefId& region, const ESM::RefId& id)
|
||||||
|
{
|
||||||
|
mWeatherManager->changeWeather(region, id);
|
||||||
|
}
|
||||||
|
|
||||||
void World::modRegion(const ESM::RefId& regionid, const std::vector<uint8_t>& chances)
|
void World::modRegion(const ESM::RefId& regionid, const std::vector<uint8_t>& chances)
|
||||||
{
|
{
|
||||||
mWeatherManager->modRegion(regionid, chances);
|
mWeatherManager->modRegion(regionid, chances);
|
||||||
|
|
@ -3133,6 +3167,11 @@ namespace MWWorld
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const osg::Vec4f& World::getSunLightPosition() const
|
||||||
|
{
|
||||||
|
return mRendering->getSunLightPosition();
|
||||||
|
}
|
||||||
|
|
||||||
float World::getSunVisibility() const
|
float World::getSunVisibility() const
|
||||||
{
|
{
|
||||||
return mWeatherManager->getSunVisibility();
|
return mWeatherManager->getSunVisibility();
|
||||||
|
|
|
||||||
|
|
@ -317,9 +317,16 @@ namespace MWWorld
|
||||||
|
|
||||||
void changeWeather(const ESM::RefId& region, const unsigned int id) override;
|
void changeWeather(const ESM::RefId& region, const unsigned int id) override;
|
||||||
|
|
||||||
int getCurrentWeather() const override;
|
void changeWeather(const ESM::RefId& region, const ESM::RefId& id) override;
|
||||||
|
|
||||||
int getNextWeather() const override;
|
const std::vector<MWWorld::Weather>& getAllWeather() const override;
|
||||||
|
|
||||||
|
int getCurrentWeatherScriptId() const override;
|
||||||
|
const MWWorld::Weather& getCurrentWeather() const override;
|
||||||
|
const MWWorld::Weather* getWeather(size_t index) const override;
|
||||||
|
const MWWorld::Weather* getWeather(const ESM::RefId& id) const override;
|
||||||
|
int getNextWeatherScriptId() const override;
|
||||||
|
const MWWorld::Weather* getNextWeather() const override;
|
||||||
|
|
||||||
float getWeatherTransition() const override;
|
float getWeatherTransition() const override;
|
||||||
|
|
||||||
|
|
@ -573,6 +580,7 @@ namespace MWWorld
|
||||||
// Allow NPCs to use torches?
|
// Allow NPCs to use torches?
|
||||||
bool useTorches() const override;
|
bool useTorches() const override;
|
||||||
|
|
||||||
|
const osg::Vec4f& getSunLightPosition() const override;
|
||||||
float getSunVisibility() const override;
|
float getSunVisibility() const override;
|
||||||
float getSunPercentage() const override;
|
float getSunPercentage() const override;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@
|
||||||
#include <components/esm3/loadnpc.hpp>
|
#include <components/esm3/loadnpc.hpp>
|
||||||
#include <components/esm3/readerscache.hpp>
|
#include <components/esm3/readerscache.hpp>
|
||||||
|
|
||||||
|
#include <gmock/gmock.h>
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
namespace MWWorld
|
namespace MWWorld
|
||||||
|
|
@ -36,7 +37,7 @@ namespace MWWorld
|
||||||
LiveCellRef<ESM::NPC> liveCellRef(cellRef, &npc);
|
LiveCellRef<ESM::NPC> liveCellRef(cellRef, &npc);
|
||||||
liveCellRef.mData.setDeletedByContentFile(true);
|
liveCellRef.mData.setDeletedByContentFile(true);
|
||||||
Ptr ptr(&liveCellRef);
|
Ptr ptr(&liveCellRef);
|
||||||
EXPECT_EQ(ptr.toString(), "deleted object0xd00002a (NPC, \"player\")");
|
EXPECT_THAT(ptr.toString(), StrCaseEq("deleted object0xd00002a (NPC, \"player\")"));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(MWWorldPtrTest, toStringShouldReturnHumanReadableTextRepresentationOfPtr)
|
TEST(MWWorldPtrTest, toStringShouldReturnHumanReadableTextRepresentationOfPtr)
|
||||||
|
|
@ -53,7 +54,7 @@ namespace MWWorld
|
||||||
cellRef.mRefNum = ESM::RefNum{ .mIndex = 0x2a, .mContentFile = 0xd };
|
cellRef.mRefNum = ESM::RefNum{ .mIndex = 0x2a, .mContentFile = 0xd };
|
||||||
LiveCellRef<ESM::NPC> liveCellRef(cellRef, &npc);
|
LiveCellRef<ESM::NPC> liveCellRef(cellRef, &npc);
|
||||||
Ptr ptr(&liveCellRef);
|
Ptr ptr(&liveCellRef);
|
||||||
EXPECT_EQ(ptr.toString(), "object0xd00002a (NPC, \"player\")");
|
EXPECT_THAT(ptr.toString(), StrCaseEq("object0xd00002a (NPC, \"player\")"));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(MWWorldPtrTest, underlyingLiveCellRefShouldBeDeregisteredOnDestruction)
|
TEST(MWWorldPtrTest, underlyingLiveCellRefShouldBeDeregisteredOnDestruction)
|
||||||
|
|
|
||||||
|
|
@ -18,37 +18,33 @@ namespace Files
|
||||||
|
|
||||||
namespace bpo = boost::program_options;
|
namespace bpo = boost::program_options;
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
#if defined(_WIN32) || defined(__WINDOWS__)
|
#if defined(_WIN32) || defined(__WINDOWS__)
|
||||||
static const char* const applicationName = "OpenMW";
|
constexpr auto applicationName = "OpenMW";
|
||||||
#else
|
#else
|
||||||
static const char* const applicationName = "openmw";
|
constexpr auto applicationName = "openmw";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static constexpr auto localToken = u8"?local?";
|
using GetPath = const std::filesystem::path& (Files::FixedPath<>::*)() const;
|
||||||
static constexpr auto userConfigToken = u8"?userconfig?";
|
constexpr std::array<std::pair<std::u8string_view, GetPath>, 4> sTokenMappings = {
|
||||||
static constexpr auto userDataToken = u8"?userdata?";
|
std::make_pair(u8"?local?", &FixedPath<>::getLocalPath),
|
||||||
static constexpr auto globalToken = u8"?global?";
|
std::make_pair(u8"?userconfig?", &FixedPath<>::getUserConfigPath),
|
||||||
|
std::make_pair(u8"?userdata?", &FixedPath<>::getUserDataPath),
|
||||||
|
std::make_pair(u8"?global?", &FixedPath<>::getGlobalDataPath),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
ConfigurationManager::ConfigurationManager(bool silent)
|
ConfigurationManager::ConfigurationManager(bool silent)
|
||||||
: mFixedPath(applicationName)
|
: mFixedPath(applicationName)
|
||||||
, mSilent(silent)
|
, mSilent(silent)
|
||||||
{
|
{
|
||||||
setupTokensMapping();
|
|
||||||
|
|
||||||
// Initialize with fixed paths, will be overridden in `readConfiguration`.
|
// Initialize with fixed paths, will be overridden in `readConfiguration`.
|
||||||
mUserDataPath = mFixedPath.getUserDataPath();
|
mUserDataPath = mFixedPath.getUserDataPath();
|
||||||
mScreenshotPath = mFixedPath.getUserDataPath() / "screenshots";
|
mScreenshotPath = mFixedPath.getUserDataPath() / "screenshots";
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfigurationManager::~ConfigurationManager() {}
|
ConfigurationManager::~ConfigurationManager() = default;
|
||||||
|
|
||||||
void ConfigurationManager::setupTokensMapping()
|
|
||||||
{
|
|
||||||
mTokensMapping.insert(std::make_pair(localToken, &FixedPath<>::getLocalPath));
|
|
||||||
mTokensMapping.insert(std::make_pair(userConfigToken, &FixedPath<>::getUserConfigPath));
|
|
||||||
mTokensMapping.insert(std::make_pair(userDataToken, &FixedPath<>::getUserDataPath));
|
|
||||||
mTokensMapping.insert(std::make_pair(globalToken, &FixedPath<>::getGlobalDataPath));
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool hasReplaceConfig(const bpo::variables_map& variables)
|
static bool hasReplaceConfig(const bpo::variables_map& variables)
|
||||||
{
|
{
|
||||||
|
|
@ -74,7 +70,7 @@ namespace Files
|
||||||
std::optional<bpo::variables_map> config = loadConfig(mFixedPath.getLocalPath(), description);
|
std::optional<bpo::variables_map> config = loadConfig(mFixedPath.getLocalPath(), description);
|
||||||
if (config)
|
if (config)
|
||||||
mActiveConfigPaths.push_back(mFixedPath.getLocalPath());
|
mActiveConfigPaths.push_back(mFixedPath.getLocalPath());
|
||||||
else
|
else if (!mFixedPath.getGlobalConfigPath().empty())
|
||||||
{
|
{
|
||||||
mActiveConfigPaths.push_back(mFixedPath.getGlobalConfigPath());
|
mActiveConfigPaths.push_back(mFixedPath.getGlobalConfigPath());
|
||||||
config = loadConfig(mFixedPath.getGlobalConfigPath(), description);
|
config = loadConfig(mFixedPath.getGlobalConfigPath(), description);
|
||||||
|
|
@ -305,15 +301,18 @@ namespace Files
|
||||||
const auto pos = str.find('?', 1);
|
const auto pos = str.find('?', 1);
|
||||||
if (pos != std::u8string::npos && pos != 0)
|
if (pos != std::u8string::npos && pos != 0)
|
||||||
{
|
{
|
||||||
auto tokenIt = mTokensMapping.find(str.substr(0, pos + 1));
|
std::u8string_view view(str);
|
||||||
if (tokenIt != mTokensMapping.end())
|
auto token = view.substr(0, pos + 1);
|
||||||
|
auto found = std::find_if(
|
||||||
|
sTokenMappings.begin(), sTokenMappings.end(), [&](const auto& item) { return item.first == token; });
|
||||||
|
if (found != sTokenMappings.end())
|
||||||
{
|
{
|
||||||
auto tempPath(((mFixedPath).*(tokenIt->second))());
|
auto tempPath(((mFixedPath).*(found->second))());
|
||||||
if (pos < str.length() - 1)
|
if (!tempPath.empty() && pos < view.length() - 1)
|
||||||
{
|
{
|
||||||
// There is something after the token, so we should
|
// There is something after the token, so we should
|
||||||
// append it to the path
|
// append it to the path
|
||||||
tempPath /= str.substr(pos + 1, str.length() - pos);
|
tempPath /= view.substr(pos + 1, view.length() - pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
path = std::move(tempPath);
|
path = std::move(tempPath);
|
||||||
|
|
|
||||||
|
|
@ -62,17 +62,12 @@ namespace Files
|
||||||
private:
|
private:
|
||||||
typedef Files::FixedPath<> FixedPathType;
|
typedef Files::FixedPath<> FixedPathType;
|
||||||
|
|
||||||
typedef const std::filesystem::path& (FixedPathType::*path_type_f)() const;
|
|
||||||
typedef std::map<std::u8string, path_type_f> TokensMappingContainer;
|
|
||||||
|
|
||||||
std::optional<boost::program_options::variables_map> loadConfig(
|
std::optional<boost::program_options::variables_map> loadConfig(
|
||||||
const std::filesystem::path& path, const boost::program_options::options_description& description) const;
|
const std::filesystem::path& path, const boost::program_options::options_description& description) const;
|
||||||
|
|
||||||
void addExtraConfigDirs(
|
void addExtraConfigDirs(
|
||||||
std::stack<std::filesystem::path>& dirs, const boost::program_options::variables_map& variables) const;
|
std::stack<std::filesystem::path>& dirs, const boost::program_options::variables_map& variables) const;
|
||||||
|
|
||||||
void setupTokensMapping();
|
|
||||||
|
|
||||||
std::vector<std::filesystem::path> mActiveConfigPaths;
|
std::vector<std::filesystem::path> mActiveConfigPaths;
|
||||||
|
|
||||||
FixedPathType mFixedPath;
|
FixedPathType mFixedPath;
|
||||||
|
|
@ -80,8 +75,6 @@ namespace Files
|
||||||
std::filesystem::path mUserDataPath;
|
std::filesystem::path mUserDataPath;
|
||||||
std::filesystem::path mScreenshotPath;
|
std::filesystem::path mScreenshotPath;
|
||||||
|
|
||||||
TokensMappingContainer mTokensMapping;
|
|
||||||
|
|
||||||
bool mSilent;
|
bool mSilent;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,21 +8,11 @@
|
||||||
|
|
||||||
namespace Files
|
namespace Files
|
||||||
{
|
{
|
||||||
inline QString getLocalConfigPathQString(const Files::ConfigurationManager& cfgMgr)
|
|
||||||
{
|
|
||||||
return Files::pathToQString(cfgMgr.getLocalPath() / openmwCfgFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline QString getUserConfigPathQString(const Files::ConfigurationManager& cfgMgr)
|
inline QString getUserConfigPathQString(const Files::ConfigurationManager& cfgMgr)
|
||||||
{
|
{
|
||||||
return Files::pathToQString(cfgMgr.getUserConfigPath() / openmwCfgFile);
|
return Files::pathToQString(cfgMgr.getUserConfigPath() / openmwCfgFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline QString getGlobalConfigPathQString(const Files::ConfigurationManager& cfgMgr)
|
|
||||||
{
|
|
||||||
return Files::pathToQString(cfgMgr.getGlobalPath() / openmwCfgFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline QStringList getActiveConfigPathsQString(const Files::ConfigurationManager& cfgMgr)
|
inline QStringList getActiveConfigPathsQString(const Files::ConfigurationManager& cfgMgr)
|
||||||
{
|
{
|
||||||
const auto& activePaths = cfgMgr.getActiveConfigPaths();
|
const auto& activePaths = cfgMgr.getActiveConfigPaths();
|
||||||
|
|
|
||||||
|
|
@ -54,19 +54,7 @@ namespace Files
|
||||||
{
|
{
|
||||||
// The concept of a global config path is absurd on Windows.
|
// The concept of a global config path is absurd on Windows.
|
||||||
// Always use local config instead.
|
// Always use local config instead.
|
||||||
// The virtual base class requires that we provide this, though.
|
return {};
|
||||||
std::filesystem::path globalPath = std::filesystem::current_path();
|
|
||||||
|
|
||||||
PWSTR cString;
|
|
||||||
HRESULT result = SHGetKnownFolderPath(FOLDERID_ProgramFiles, 0, nullptr, &cString);
|
|
||||||
if (SUCCEEDED(result))
|
|
||||||
globalPath = std::filesystem::path(cString);
|
|
||||||
else
|
|
||||||
Log(Debug::Error) << "Error " << result << " when getting Program Files path";
|
|
||||||
|
|
||||||
CoTaskMemFree(cString);
|
|
||||||
|
|
||||||
return globalPath / mName;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::filesystem::path WindowsPath::getLocalPath() const
|
std::filesystem::path WindowsPath::getLocalPath() const
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ namespace Files
|
||||||
std::filesystem::path getUserDataPath() const;
|
std::filesystem::path getUserDataPath() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Returns "X:\Program Files\"
|
* \brief Returns an empty path
|
||||||
*
|
*
|
||||||
* \return std::filesystem::path
|
* \return std::filesystem::path
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
7
extern/sol3/README.md
vendored
7
extern/sol3/README.md
vendored
|
|
@ -1,5 +1,8 @@
|
||||||
The code in this directory is copied from https://github.com/ThePhD/sol2.git (64096348465b980e2f1d0e5ba9cbeea8782e8f27)
|
The code in this directory is copied from https://github.com/ThePhD/sol2.git (c1f95a773c6f8f4fde8ca3efe872e7286afe4444) and has been patched to include
|
||||||
|
|
||||||
Additional changes include cherry-picking upstream commit d805d027e0a0a7222e936926139f06e23828ce9f to fix compilation under Clang 19.
|
https://github.com/ThePhD/sol2/pull/1674 (71d85143ad69164f5f52c3bdab91fb503c676eb4)
|
||||||
|
https://github.com/ThePhD/sol2/pull/1676 (a6872ef46b08704b9069ebf83161f4637459ce63)
|
||||||
|
https://github.com/ThePhD/sol2/pull/1716 (5b6881ed94c795298eae72b6848308e9a37e42c5)
|
||||||
|
https://github.com/ThePhD/sol2/pull/1722 (ab874eb0e8ef8aea4c10074a89efa25f62a29d9a)
|
||||||
|
|
||||||
License: MIT
|
License: MIT
|
||||||
|
|
|
||||||
47
extern/sol3/sol/abort.hpp
vendored
Normal file
47
extern/sol3/sol/abort.hpp
vendored
Normal file
|
|
@ -0,0 +1,47 @@
|
||||||
|
// sol2
|
||||||
|
|
||||||
|
// The MIT License (MIT)
|
||||||
|
|
||||||
|
// Copyright (c) 2013-2022 Rapptz, ThePhD and contributors
|
||||||
|
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
|
// this software and associated documentation files (the "Software"), to deal in
|
||||||
|
// the Software without restriction, including without limitation the rights to
|
||||||
|
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||||
|
// the Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
|
// subject to the following conditions:
|
||||||
|
|
||||||
|
// The above copyright notice and this permission notice shall be included in all
|
||||||
|
// copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
#ifndef SOL_ABORT_HPP
|
||||||
|
#define SOL_ABORT_HPP
|
||||||
|
|
||||||
|
#include <sol/version.hpp>
|
||||||
|
|
||||||
|
#include <sol/base_traits.hpp>
|
||||||
|
|
||||||
|
#include <cstdlib>
|
||||||
|
|
||||||
|
// clang-format off
|
||||||
|
#if SOL_IS_ON(SOL_DEBUG_BUILD)
|
||||||
|
#if SOL_IS_ON(SOL_COMPILER_VCXX)
|
||||||
|
#define SOL_DEBUG_ABORT() \
|
||||||
|
if (true) { ::std::abort(); } \
|
||||||
|
static_assert(true, "")
|
||||||
|
#else
|
||||||
|
#define SOL_DEBUG_ABORT() ::std::abort()
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
#define SOL_DEBUG_ABORT() static_assert(true, "")
|
||||||
|
#endif
|
||||||
|
// clang-format on
|
||||||
|
|
||||||
|
#endif // SOL_ABORT_HPP
|
||||||
2
extern/sol3/sol/as_args.hpp
vendored
2
extern/sol3/sol/as_args.hpp
vendored
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
// The MIT License (MIT)
|
// The MIT License (MIT)
|
||||||
|
|
||||||
// Copyright (c) 2013-2021 Rapptz, ThePhD and contributors
|
// Copyright (c) 2013-2022 Rapptz, ThePhD and contributors
|
||||||
|
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
// this software and associated documentation files (the "Software"), to deal in
|
// this software and associated documentation files (the "Software"), to deal in
|
||||||
|
|
|
||||||
2
extern/sol3/sol/as_returns.hpp
vendored
2
extern/sol3/sol/as_returns.hpp
vendored
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
// The MIT License (MIT)
|
// The MIT License (MIT)
|
||||||
|
|
||||||
// Copyright (c) 2013-2021 Rapptz, ThePhD and contributors
|
// Copyright (c) 2013-2022 Rapptz, ThePhD and contributors
|
||||||
|
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
// this software and associated documentation files (the "Software"), to deal in
|
// this software and associated documentation files (the "Software"), to deal in
|
||||||
|
|
|
||||||
198
extern/sol3/sol/assert.hpp
vendored
198
extern/sol3/sol/assert.hpp
vendored
|
|
@ -1,99 +1,99 @@
|
||||||
// sol2
|
// sol2
|
||||||
|
|
||||||
// The MIT License (MIT)
|
// The MIT License (MIT)
|
||||||
|
|
||||||
// Copyright (c) 2013-2021 Rapptz, ThePhD and contributors
|
// Copyright (c) 2013-2022 Rapptz, ThePhD and contributors
|
||||||
|
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
// this software and associated documentation files (the "Software"), to deal in
|
// this software and associated documentation files (the "Software"), to deal in
|
||||||
// the Software without restriction, including without limitation the rights to
|
// the Software without restriction, including without limitation the rights to
|
||||||
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||||
// the Software, and to permit persons to whom the Software is furnished to do so,
|
// the Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
// subject to the following conditions:
|
// subject to the following conditions:
|
||||||
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
// The above copyright notice and this permission notice shall be included in all
|
||||||
// copies or substantial portions of the Software.
|
// copies or substantial portions of the Software.
|
||||||
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#ifndef SOL_ASSERT_HPP
|
#ifndef SOL_ASSERT_HPP
|
||||||
#define SOL_ASSERT_HPP
|
#define SOL_ASSERT_HPP
|
||||||
|
|
||||||
#include <sol/forward.hpp>
|
#include <sol/forward.hpp>
|
||||||
|
|
||||||
#if SOL_IS_ON(SOL2_CI_I_)
|
#if SOL_IS_ON(SOL2_CI)
|
||||||
|
|
||||||
struct pre_main {
|
struct pre_main {
|
||||||
pre_main() {
|
pre_main() {
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
_set_abort_behavior(0, _WRITE_ABORT_MSG);
|
_set_abort_behavior(0, _WRITE_ABORT_MSG);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
} inline sol2_ci_dont_lock_ci_please = {};
|
} inline sol2_ci_dont_lock_ci_please = {};
|
||||||
|
|
||||||
#endif // Prevent lockup when doing Continuous Integration
|
#endif // Prevent lockup when doing Continuous Integration
|
||||||
|
|
||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
|
|
||||||
#if SOL_IS_ON(SOL_USER_C_ASSERT_I_)
|
#if SOL_IS_ON(SOL_USER_ASSERT)
|
||||||
#define sol_c_assert(...) SOL_C_ASSERT(__VA_ARGS__)
|
#define SOL_ASSERT(...) SOL_C_ASSERT(__VA_ARGS__)
|
||||||
#else
|
#else
|
||||||
#if SOL_IS_ON(SOL_DEBUG_BUILD_I_)
|
#if SOL_IS_ON(SOL_DEBUG_BUILD)
|
||||||
#include <exception>
|
#include <exception>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
|
||||||
#define sol_c_assert(...) \
|
#define SOL_ASSERT(...) \
|
||||||
do { \
|
do { \
|
||||||
if (!(__VA_ARGS__)) { \
|
if (!(__VA_ARGS__)) { \
|
||||||
std::cerr << "Assertion `" #__VA_ARGS__ "` failed in " << __FILE__ << " line " << __LINE__ << std::endl; \
|
std::cerr << "Assertion `" #__VA_ARGS__ "` failed in " << __FILE__ << " line " << __LINE__ << std::endl; \
|
||||||
std::terminate(); \
|
std::terminate(); \
|
||||||
} \
|
} \
|
||||||
} while (false)
|
} while (false)
|
||||||
#else
|
#else
|
||||||
#define sol_c_assert(...) \
|
#define SOL_ASSERT(...) \
|
||||||
do { \
|
do { \
|
||||||
if (false) { \
|
if (false) { \
|
||||||
(void)(__VA_ARGS__); \
|
(void)(__VA_ARGS__); \
|
||||||
} \
|
} \
|
||||||
} while (false)
|
} while (false)
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if SOL_IS_ON(SOL_USER_M_ASSERT_I_)
|
#if SOL_IS_ON(SOL_USER_ASSERT_MSG)
|
||||||
#define sol_m_assert(message, ...) SOL_M_ASSERT(message, __VA_ARGS__)
|
#define SOL_ASSERT_MSG(message, ...) SOL_ASSERT_MSG(message, __VA_ARGS__)
|
||||||
#else
|
#else
|
||||||
#if SOL_IS_ON(SOL_DEBUG_BUILD_I_)
|
#if SOL_IS_ON(SOL_DEBUG_BUILD)
|
||||||
#include <exception>
|
#include <exception>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
|
||||||
#define sol_m_assert(message, ...) \
|
#define SOL_ASSERT_MSG(message, ...) \
|
||||||
do { \
|
do { \
|
||||||
if (!(__VA_ARGS__)) { \
|
if (!(__VA_ARGS__)) { \
|
||||||
std::cerr << "Assertion `" #__VA_ARGS__ "` failed in " << __FILE__ << " line " << __LINE__ << ": " << message << std::endl; \
|
std::cerr << "Assertion `" #__VA_ARGS__ "` failed in " << __FILE__ << " line " << __LINE__ << ": " << message << std::endl; \
|
||||||
std::terminate(); \
|
std::terminate(); \
|
||||||
} \
|
} \
|
||||||
} while (false)
|
} while (false)
|
||||||
#else
|
#else
|
||||||
#define sol_m_assert(message, ...) \
|
#define SOL_ASSERT_MSG(message, ...) \
|
||||||
do { \
|
do { \
|
||||||
if (false) { \
|
if (false) { \
|
||||||
(void)(__VA_ARGS__); \
|
(void)(__VA_ARGS__); \
|
||||||
(void)sizeof(message); \
|
(void)sizeof(message); \
|
||||||
} \
|
} \
|
||||||
} while (false)
|
} while (false)
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
#endif // SOL_ASSERT_HPP
|
#endif // SOL_ASSERT_HPP
|
||||||
|
|
|
||||||
279
extern/sol3/sol/base_traits.hpp
vendored
279
extern/sol3/sol/base_traits.hpp
vendored
|
|
@ -1,123 +1,156 @@
|
||||||
// sol2
|
// sol2
|
||||||
|
|
||||||
// The MIT License (MIT)
|
// The MIT License (MIT)
|
||||||
|
|
||||||
// Copyright (c) 2013-2021 Rapptz, ThePhD and contributors
|
// Copyright (c) 2013-2022 Rapptz, ThePhD and contributors
|
||||||
|
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
// this software and associated documentation files (the "Software"), to deal in
|
// this software and associated documentation files (the "Software"), to deal in
|
||||||
// the Software without restriction, including without limitation the rights to
|
// the Software without restriction, including without limitation the rights to
|
||||||
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||||
// the Software, and to permit persons to whom the Software is furnished to do so,
|
// the Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
// subject to the following conditions:
|
// subject to the following conditions:
|
||||||
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
// The above copyright notice and this permission notice shall be included in all
|
||||||
// copies or substantial portions of the Software.
|
// copies or substantial portions of the Software.
|
||||||
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
#ifndef SOL_BASE_TRAITS_HPP
|
#ifndef SOL_BASE_TRAITS_HPP
|
||||||
#define SOL_BASE_TRAITS_HPP
|
#define SOL_BASE_TRAITS_HPP
|
||||||
|
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
|
|
||||||
namespace sol {
|
namespace sol {
|
||||||
namespace detail {
|
namespace detail {
|
||||||
struct unchecked_t { };
|
struct unchecked_t { };
|
||||||
const unchecked_t unchecked = unchecked_t {};
|
const unchecked_t unchecked = unchecked_t {};
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
|
|
||||||
namespace meta {
|
namespace meta {
|
||||||
using sfinae_yes_t = std::true_type;
|
using sfinae_yes_t = std::true_type;
|
||||||
using sfinae_no_t = std::false_type;
|
using sfinae_no_t = std::false_type;
|
||||||
|
|
||||||
template <typename...>
|
template <typename...>
|
||||||
using void_t = void;
|
using void_t = void;
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
using unqualified = std::remove_cv<std::remove_reference_t<T>>;
|
using unqualified = std::remove_cv<std::remove_reference_t<T>>;
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
using unqualified_t = typename unqualified<T>::type;
|
using unqualified_t = typename unqualified<T>::type;
|
||||||
|
|
||||||
namespace meta_detail {
|
namespace meta_detail {
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct unqualified_non_alias : unqualified<T> { };
|
struct unqualified_non_alias : unqualified<T> { };
|
||||||
|
|
||||||
template <template <class...> class Test, class, class... Args>
|
template <template <class...> class Test, class, class... Args>
|
||||||
struct is_detected : std::false_type { };
|
struct is_detected : std::false_type { };
|
||||||
|
|
||||||
template <template <class...> class Test, class... Args>
|
template <template <class...> class Test, class... Args>
|
||||||
struct is_detected<Test, void_t<Test<Args...>>, Args...> : std::true_type { };
|
struct is_detected<Test, void_t<Test<Args...>>, Args...> : std::true_type { };
|
||||||
} // namespace meta_detail
|
} // namespace meta_detail
|
||||||
|
|
||||||
template <template <class...> class Trait, class... Args>
|
template <template <class...> class Trait, class... Args>
|
||||||
using is_detected = typename meta_detail::is_detected<Trait, void, Args...>::type;
|
using is_detected = typename meta_detail::is_detected<Trait, void, Args...>::type;
|
||||||
|
|
||||||
template <template <class...> class Trait, class... Args>
|
template <template <class...> class Trait, class... Args>
|
||||||
constexpr inline bool is_detected_v = is_detected<Trait, Args...>::value;
|
constexpr inline bool is_detected_v = is_detected<Trait, Args...>::value;
|
||||||
|
|
||||||
template <std::size_t I>
|
template <typename _Default, typename _Void, template <typename...> typename _Op, typename... _Args>
|
||||||
using index_value = std::integral_constant<std::size_t, I>;
|
class detector {
|
||||||
|
public:
|
||||||
template <bool>
|
using value_t = ::std::false_type;
|
||||||
struct conditional {
|
using type = _Default;
|
||||||
template <typename T, typename U>
|
};
|
||||||
using type = T;
|
|
||||||
};
|
template <typename _Default, template <typename...> typename _Op, typename... _Args>
|
||||||
|
class detector<_Default, void_t<_Op<_Args...>>, _Op, _Args...> {
|
||||||
template <>
|
public:
|
||||||
struct conditional<false> {
|
using value_t = ::std::true_type;
|
||||||
template <typename T, typename U>
|
using type = _Op<_Args...>;
|
||||||
using type = U;
|
};
|
||||||
};
|
|
||||||
|
class nonesuch {
|
||||||
template <bool B, typename T, typename U>
|
public:
|
||||||
using conditional_t = typename conditional<B>::template type<T, U>;
|
~nonesuch() = delete;
|
||||||
|
nonesuch(nonesuch const&) = delete;
|
||||||
namespace meta_detail {
|
nonesuch& operator=(nonesuch const&) = delete;
|
||||||
template <typename T, template <typename...> class Templ>
|
};
|
||||||
struct is_specialization_of : std::false_type { };
|
|
||||||
template <typename... T, template <typename...> class Templ>
|
template <template <typename...> typename _Op, typename... _Args>
|
||||||
struct is_specialization_of<Templ<T...>, Templ> : std::true_type { };
|
using detected_t = typename detector<nonesuch, void, _Op, _Args...>::type;
|
||||||
} // namespace meta_detail
|
|
||||||
|
template <typename _Default, template <typename...> typename _Op, typename... _Args>
|
||||||
template <typename T, template <typename...> class Templ>
|
using detected_or = detector<_Default, void, _Op, _Args...>;
|
||||||
using is_specialization_of = meta_detail::is_specialization_of<std::remove_cv_t<T>, Templ>;
|
|
||||||
|
template <typename _Default, template <typename...> typename _Op, typename... _Args>
|
||||||
template <typename T, template <typename...> class Templ>
|
using detected_or_t = typename detector<_Default, void, _Op, _Args...>::type;
|
||||||
inline constexpr bool is_specialization_of_v = is_specialization_of<std::remove_cv_t<T>, Templ>::value;
|
|
||||||
|
template <typename _Default, template <typename...> typename _Op, typename... _Args>
|
||||||
template <typename T>
|
constexpr inline bool detected_or_v = detector<_Default, void, _Op, _Args...>::value;
|
||||||
struct identity {
|
|
||||||
typedef T type;
|
template <std::size_t I>
|
||||||
};
|
using index_value = std::integral_constant<std::size_t, I>;
|
||||||
|
|
||||||
template <typename T>
|
template <bool>
|
||||||
using identity_t = typename identity<T>::type;
|
struct conditional {
|
||||||
|
template <typename T, typename U>
|
||||||
template <typename T>
|
using type = T;
|
||||||
using is_builtin_type = std::integral_constant<bool, std::is_arithmetic<T>::value || std::is_pointer<T>::value || std::is_array<T>::value>;
|
};
|
||||||
|
|
||||||
namespace meta_detail {
|
template <>
|
||||||
template <typename T, typename = void>
|
struct conditional<false> {
|
||||||
struct has_internal_marker_impl : std::false_type { };
|
template <typename T, typename U>
|
||||||
template <typename T>
|
using type = U;
|
||||||
struct has_internal_marker_impl<T, void_t<typename T::SOL_INTERNAL_UNSPECIALIZED_MARKER_>> : std::true_type { };
|
};
|
||||||
|
|
||||||
template <typename T>
|
template <bool B, typename T, typename U>
|
||||||
using has_internal_marker = has_internal_marker_impl<T>;
|
using conditional_t = typename conditional<B>::template type<T, U>;
|
||||||
|
|
||||||
template <typename T>
|
namespace meta_detail {
|
||||||
constexpr inline bool has_internal_marker_v = has_internal_marker<T>::value;
|
template <typename T, template <typename...> class Templ>
|
||||||
} // namespace meta_detail
|
struct is_specialization_of : std::false_type { };
|
||||||
|
template <typename... T, template <typename...> class Templ>
|
||||||
} // namespace meta
|
struct is_specialization_of<Templ<T...>, Templ> : std::true_type { };
|
||||||
} // namespace sol
|
} // namespace meta_detail
|
||||||
|
|
||||||
#endif // SOL_BASE_TRAITS_HPP
|
template <typename T, template <typename...> class Templ>
|
||||||
|
using is_specialization_of = meta_detail::is_specialization_of<std::remove_cv_t<T>, Templ>;
|
||||||
|
|
||||||
|
template <typename T, template <typename...> class Templ>
|
||||||
|
inline constexpr bool is_specialization_of_v = is_specialization_of<std::remove_cv_t<T>, Templ>::value;
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct identity {
|
||||||
|
typedef T type;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
using identity_t = typename identity<T>::type;
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
using is_builtin_type = std::integral_constant<bool, std::is_arithmetic<T>::value || std::is_pointer<T>::value || std::is_array<T>::value>;
|
||||||
|
|
||||||
|
namespace meta_detail {
|
||||||
|
template <typename T, typename = void>
|
||||||
|
struct has_internal_marker_impl : std::false_type { };
|
||||||
|
template <typename T>
|
||||||
|
struct has_internal_marker_impl<T, void_t<typename T::SOL_INTERNAL_UNSPECIALIZED_MARKER_>> : std::true_type { };
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
using has_internal_marker = has_internal_marker_impl<T>;
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
constexpr inline bool has_internal_marker_v = has_internal_marker<T>::value;
|
||||||
|
} // namespace meta_detail
|
||||||
|
|
||||||
|
} // namespace meta
|
||||||
|
} // namespace sol
|
||||||
|
|
||||||
|
#endif // SOL_BASE_TRAITS_HPP
|
||||||
|
|
|
||||||
10
extern/sol3/sol/bind_traits.hpp
vendored
10
extern/sol3/sol/bind_traits.hpp
vendored
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
// The MIT License (MIT)
|
// The MIT License (MIT)
|
||||||
|
|
||||||
// Copyright (c) 2013-2021 Rapptz, ThePhD and contributors
|
// Copyright (c) 2013-2022 Rapptz, ThePhD and contributors
|
||||||
|
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
// this software and associated documentation files (the "Software"), to deal in
|
// this software and associated documentation files (the "Software"), to deal in
|
||||||
|
|
@ -31,7 +31,7 @@
|
||||||
namespace sol { namespace meta {
|
namespace sol { namespace meta {
|
||||||
namespace meta_detail {
|
namespace meta_detail {
|
||||||
template <typename F>
|
template <typename F>
|
||||||
using detect_deducible_signature = decltype(&F::operator(), void());
|
using detect_deducible_signature = decltype(&F::operator());
|
||||||
} // namespace meta_detail
|
} // namespace meta_detail
|
||||||
|
|
||||||
template <typename F>
|
template <typename F>
|
||||||
|
|
@ -196,7 +196,7 @@ namespace sol { namespace meta {
|
||||||
typedef R (T::*function_pointer_type)(Args..., ...) const volatile&&;
|
typedef R (T::*function_pointer_type)(Args..., ...) const volatile&&;
|
||||||
};
|
};
|
||||||
|
|
||||||
#if SOL_IS_ON(SOL_USE_NOEXCEPT_FUNCTION_TYPE_I_)
|
#if SOL_IS_ON(SOL_USE_NOEXCEPT_FUNCTION_TYPE)
|
||||||
|
|
||||||
template <typename R, typename... Args>
|
template <typename R, typename... Args>
|
||||||
struct fx_traits<R(Args...) noexcept, false> : public basic_traits<true, false, void, R, Args...> {
|
struct fx_traits<R(Args...) noexcept, false> : public basic_traits<true, false, void, R, Args...> {
|
||||||
|
|
@ -311,7 +311,7 @@ namespace sol { namespace meta {
|
||||||
|
|
||||||
#endif // noexcept is part of a function's type
|
#endif // noexcept is part of a function's type
|
||||||
|
|
||||||
#if SOL_IS_ON(SOL_COMPILER_VCXX_I_) && SOL_IS_ON(SOL_PLATFORM_X86_I_)
|
#if SOL_IS_ON(SOL_COMPILER_VCXX) && SOL_IS_ON(SOL_PLATFORM_X86)
|
||||||
template <typename R, typename... Args>
|
template <typename R, typename... Args>
|
||||||
struct fx_traits<R __stdcall(Args...), false> : public basic_traits<false, false, void, R, Args...> {
|
struct fx_traits<R __stdcall(Args...), false> : public basic_traits<false, false, void, R, Args...> {
|
||||||
typedef R(__stdcall* function_pointer_type)(Args...);
|
typedef R(__stdcall* function_pointer_type)(Args...);
|
||||||
|
|
@ -369,7 +369,7 @@ namespace sol { namespace meta {
|
||||||
typedef R (__stdcall T::*function_pointer_type)(Args...) const volatile&&;
|
typedef R (__stdcall T::*function_pointer_type)(Args...) const volatile&&;
|
||||||
};
|
};
|
||||||
|
|
||||||
#if SOL_IS_ON(SOL_USE_NOEXCEPT_FUNCTION_TYPE_I_)
|
#if SOL_IS_ON(SOL_USE_NOEXCEPT_FUNCTION_TYPE)
|
||||||
|
|
||||||
template <typename R, typename... Args>
|
template <typename R, typename... Args>
|
||||||
struct fx_traits<R __stdcall(Args...) noexcept, false> : public basic_traits<true, false, void, R, Args...> {
|
struct fx_traits<R __stdcall(Args...) noexcept, false> : public basic_traits<true, false, void, R, Args...> {
|
||||||
|
|
|
||||||
242
extern/sol3/sol/bytecode.hpp
vendored
242
extern/sol3/sol/bytecode.hpp
vendored
|
|
@ -1,121 +1,121 @@
|
||||||
// sol2
|
// sol2
|
||||||
|
|
||||||
// The MIT License (MIT)
|
// The MIT License (MIT)
|
||||||
|
|
||||||
// Copyright (c) 2013-2021 Rapptz, ThePhD and contributors
|
// Copyright (c) 2013-2022 Rapptz, ThePhD and contributors
|
||||||
|
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
// this software and associated documentation files (the "Software"), to deal in
|
// this software and associated documentation files (the "Software"), to deal in
|
||||||
// the Software without restriction, including without limitation the rights to
|
// the Software without restriction, including without limitation the rights to
|
||||||
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||||
// the Software, and to permit persons to whom the Software is furnished to do so,
|
// the Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
// subject to the following conditions:
|
// subject to the following conditions:
|
||||||
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
// The above copyright notice and this permission notice shall be included in all
|
||||||
// copies or substantial portions of the Software.
|
// copies or substantial portions of the Software.
|
||||||
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
#ifndef SOL_BYTECODE_HPP
|
#ifndef SOL_BYTECODE_HPP
|
||||||
#define SOL_BYTECODE_HPP
|
#define SOL_BYTECODE_HPP
|
||||||
|
|
||||||
#include <sol/compatibility.hpp>
|
#include <sol/compatibility.hpp>
|
||||||
#include <sol/string_view.hpp>
|
#include <sol/string_view.hpp>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
|
|
||||||
namespace sol {
|
namespace sol {
|
||||||
|
|
||||||
template <typename Allocator = std::allocator<std::byte>>
|
template <typename Allocator = std::allocator<std::byte>>
|
||||||
class basic_bytecode : private std::vector<std::byte, Allocator> {
|
class basic_bytecode : private std::vector<std::byte, Allocator> {
|
||||||
private:
|
private:
|
||||||
using base_t = std::vector<std::byte, Allocator>;
|
using base_t = std::vector<std::byte, Allocator>;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
using typename base_t::allocator_type;
|
using typename base_t::allocator_type;
|
||||||
using typename base_t::const_iterator;
|
using typename base_t::const_iterator;
|
||||||
using typename base_t::const_pointer;
|
using typename base_t::const_pointer;
|
||||||
using typename base_t::const_reference;
|
using typename base_t::const_reference;
|
||||||
using typename base_t::const_reverse_iterator;
|
using typename base_t::const_reverse_iterator;
|
||||||
using typename base_t::difference_type;
|
using typename base_t::difference_type;
|
||||||
using typename base_t::iterator;
|
using typename base_t::iterator;
|
||||||
using typename base_t::pointer;
|
using typename base_t::pointer;
|
||||||
using typename base_t::reference;
|
using typename base_t::reference;
|
||||||
using typename base_t::reverse_iterator;
|
using typename base_t::reverse_iterator;
|
||||||
using typename base_t::size_type;
|
using typename base_t::size_type;
|
||||||
using typename base_t::value_type;
|
using typename base_t::value_type;
|
||||||
|
|
||||||
using base_t::base_t;
|
using base_t::base_t;
|
||||||
using base_t::operator=;
|
using base_t::operator=;
|
||||||
|
|
||||||
using base_t::data;
|
using base_t::data;
|
||||||
using base_t::empty;
|
using base_t::empty;
|
||||||
using base_t::max_size;
|
using base_t::max_size;
|
||||||
using base_t::size;
|
using base_t::size;
|
||||||
|
|
||||||
using base_t::at;
|
using base_t::at;
|
||||||
using base_t::operator[];
|
using base_t::operator[];
|
||||||
using base_t::back;
|
using base_t::back;
|
||||||
using base_t::front;
|
using base_t::front;
|
||||||
|
|
||||||
using base_t::begin;
|
using base_t::begin;
|
||||||
using base_t::cbegin;
|
using base_t::cbegin;
|
||||||
using base_t::cend;
|
using base_t::cend;
|
||||||
using base_t::end;
|
using base_t::end;
|
||||||
|
|
||||||
using base_t::crbegin;
|
using base_t::crbegin;
|
||||||
using base_t::crend;
|
using base_t::crend;
|
||||||
using base_t::rbegin;
|
using base_t::rbegin;
|
||||||
using base_t::rend;
|
using base_t::rend;
|
||||||
|
|
||||||
|
|
||||||
using base_t::get_allocator;
|
using base_t::get_allocator;
|
||||||
using base_t::swap;
|
using base_t::swap;
|
||||||
|
|
||||||
using base_t::clear;
|
using base_t::clear;
|
||||||
using base_t::emplace;
|
using base_t::emplace;
|
||||||
using base_t::emplace_back;
|
using base_t::emplace_back;
|
||||||
using base_t::erase;
|
using base_t::erase;
|
||||||
using base_t::insert;
|
using base_t::insert;
|
||||||
using base_t::pop_back;
|
using base_t::pop_back;
|
||||||
using base_t::push_back;
|
using base_t::push_back;
|
||||||
using base_t::reserve;
|
using base_t::reserve;
|
||||||
using base_t::resize;
|
using base_t::resize;
|
||||||
using base_t::shrink_to_fit;
|
using base_t::shrink_to_fit;
|
||||||
|
|
||||||
string_view as_string_view() const {
|
string_view as_string_view() const {
|
||||||
return string_view(reinterpret_cast<const char*>(this->data()), this->size());
|
return string_view(reinterpret_cast<const char*>(this->data()), this->size());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename Container>
|
template <typename Container>
|
||||||
inline int basic_insert_dump_writer(lua_State*, const void* memory, size_t memory_size, void* userdata_pointer) {
|
inline int basic_insert_dump_writer(lua_State*, const void* memory, size_t memory_size, void* userdata_pointer) {
|
||||||
using storage_t = Container;
|
using storage_t = Container;
|
||||||
const std::byte* p_code = static_cast<const std::byte*>(memory);
|
const std::byte* p_code = static_cast<const std::byte*>(memory);
|
||||||
storage_t& bc = *static_cast<storage_t*>(userdata_pointer);
|
storage_t& bc = *static_cast<storage_t*>(userdata_pointer);
|
||||||
#if SOL_IS_OFF(SOL_EXCEPTIONS_I_)
|
#if SOL_IS_OFF(SOL_EXCEPTIONS)
|
||||||
bc.insert(bc.cend(), p_code, p_code + memory_size);
|
bc.insert(bc.cend(), p_code, p_code + memory_size);
|
||||||
#else
|
#else
|
||||||
try {
|
try {
|
||||||
bc.insert(bc.cend(), p_code, p_code + memory_size);
|
bc.insert(bc.cend(), p_code, p_code + memory_size);
|
||||||
}
|
}
|
||||||
catch (...) {
|
catch (...) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
using bytecode = basic_bytecode<>;
|
using bytecode = basic_bytecode<>;
|
||||||
|
|
||||||
constexpr inline auto bytecode_dump_writer = &basic_insert_dump_writer<bytecode>;
|
constexpr inline auto bytecode_dump_writer = &basic_insert_dump_writer<bytecode>;
|
||||||
|
|
||||||
} // namespace sol
|
} // namespace sol
|
||||||
|
|
||||||
#endif // SOL_BYTECODE_HPP
|
#endif // SOL_BYTECODE_HPP
|
||||||
|
|
|
||||||
32
extern/sol3/sol/call.hpp
vendored
32
extern/sol3/sol/call.hpp
vendored
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
// The MIT License (MIT)
|
// The MIT License (MIT)
|
||||||
|
|
||||||
// Copyright (c) 2013-2021 Rapptz, ThePhD and contributors
|
// Copyright (c) 2013-2022 Rapptz, ThePhD and contributors
|
||||||
|
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
// this software and associated documentation files (the "Software"), to deal in
|
// this software and associated documentation files (the "Software"), to deal in
|
||||||
|
|
@ -54,7 +54,7 @@ namespace sol {
|
||||||
lua_createtable(L, static_cast<int>(sizeof...(In)), 0);
|
lua_createtable(L, static_cast<int>(sizeof...(In)), 0);
|
||||||
stack_reference deps(L, -1);
|
stack_reference deps(L, -1);
|
||||||
auto per_dep = [&L, &deps](int i) {
|
auto per_dep = [&L, &deps](int i) {
|
||||||
#if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_)
|
#if SOL_IS_ON(SOL_SAFE_STACK_CHECK)
|
||||||
luaL_checkstack(L, 1, detail::not_enough_stack_space_generic);
|
luaL_checkstack(L, 1, detail::not_enough_stack_space_generic);
|
||||||
#endif // make sure stack doesn't overflow
|
#endif // make sure stack doesn't overflow
|
||||||
lua_pushvalue(L, i);
|
lua_pushvalue(L, i);
|
||||||
|
|
@ -79,7 +79,7 @@ namespace sol {
|
||||||
}
|
}
|
||||||
lua_createtable(L, static_cast<int>(sdeps.size()), 0);
|
lua_createtable(L, static_cast<int>(sdeps.size()), 0);
|
||||||
stack_reference deps(L, -1);
|
stack_reference deps(L, -1);
|
||||||
#if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_)
|
#if SOL_IS_ON(SOL_SAFE_STACK_CHECK)
|
||||||
luaL_checkstack(L, static_cast<int>(sdeps.size()), detail::not_enough_stack_space_generic);
|
luaL_checkstack(L, static_cast<int>(sdeps.size()), detail::not_enough_stack_space_generic);
|
||||||
#endif // make sure stack doesn't overflow
|
#endif // make sure stack doesn't overflow
|
||||||
for (std::size_t i = 0; i < sdeps.size(); ++i) {
|
for (std::size_t i = 0; i < sdeps.size(); ++i) {
|
||||||
|
|
@ -429,7 +429,7 @@ namespace sol {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#if SOL_IS_ON(SOL_USE_NOEXCEPT_FUNCTION_TYPE_I_)
|
#if SOL_IS_ON(SOL_USE_NOEXCEPT_FUNCTION_TYPE)
|
||||||
template <bool is_index, bool is_variable, bool checked, int boost, bool clean_stack, typename C>
|
template <bool is_index, bool is_variable, bool checked, int boost, bool clean_stack, typename C>
|
||||||
struct agnostic_lua_call_wrapper<detail::lua_CFunction_noexcept, is_index, is_variable, checked, boost, clean_stack, C> {
|
struct agnostic_lua_call_wrapper<detail::lua_CFunction_noexcept, is_index, is_variable, checked, boost, clean_stack, C> {
|
||||||
static int call(lua_State* L, detail::lua_CFunction_noexcept f) {
|
static int call(lua_State* L, detail::lua_CFunction_noexcept f) {
|
||||||
|
|
@ -478,12 +478,13 @@ namespace sol {
|
||||||
using object_type = typename wrap::object_type;
|
using object_type = typename wrap::object_type;
|
||||||
if constexpr (sizeof...(Args) < 1) {
|
if constexpr (sizeof...(Args) < 1) {
|
||||||
using Ta = meta::conditional_t<std::is_void_v<T>, object_type, T>;
|
using Ta = meta::conditional_t<std::is_void_v<T>, object_type, T>;
|
||||||
static_assert(std::is_base_of_v<object_type, Ta>,
|
static_assert(std::is_same_v<object_type, Ta> || std::is_base_of_v<object_type, Ta>,
|
||||||
"It seems like you might have accidentally bound a class type with a member function method that does not correspond to the "
|
"It seems like you might have accidentally bound a class type with a member function method that does not correspond to the "
|
||||||
"class. For example, there could be a small type in your new_usertype<T>(...) binding, where you specify one class \"T\" "
|
"class. For example, there could be a small type in your new_usertype<T>(...) binding, where you specify one class \"T\" "
|
||||||
"but then bind member methods from a complete unrelated class. Check things over!");
|
"but then bind member methods from a complete unrelated class. Check things over!");
|
||||||
#if SOL_IS_ON(SOL_SAFE_USERTYPE_I_)
|
#if SOL_IS_ON(SOL_SAFE_USERTYPE)
|
||||||
auto maybeo = stack::check_get<Ta*>(L, 1);
|
stack::record tracking {};
|
||||||
|
auto maybeo = stack::stack_detail::check_get_arg<Ta*>(L, 1, &no_panic, tracking);
|
||||||
if (!maybeo || maybeo.value() == nullptr) {
|
if (!maybeo || maybeo.value() == nullptr) {
|
||||||
return luaL_error(L,
|
return luaL_error(L,
|
||||||
"sol: received nil for 'self' argument (use ':' for accessing member functions, make sure member variables are "
|
"sol: received nil for 'self' argument (use ':' for accessing member functions, make sure member variables are "
|
||||||
|
|
@ -511,12 +512,13 @@ namespace sol {
|
||||||
if constexpr (is_index) {
|
if constexpr (is_index) {
|
||||||
if constexpr (sizeof...(Args) < 1) {
|
if constexpr (sizeof...(Args) < 1) {
|
||||||
using Ta = meta::conditional_t<std::is_void_v<T>, object_type, T>;
|
using Ta = meta::conditional_t<std::is_void_v<T>, object_type, T>;
|
||||||
static_assert(std::is_base_of_v<object_type, Ta>,
|
static_assert(std::is_same_v<object_type, Ta> || std::is_base_of_v<object_type, Ta>,
|
||||||
"It seems like you might have accidentally bound a class type with a member function method that does not correspond "
|
"It seems like you might have accidentally bound a class type with a member function method that does not correspond "
|
||||||
"to the class. For example, there could be a small type in your new_usertype<T>(...) binding, where you specify one "
|
"to the class. For example, there could be a small type in your new_usertype<T>(...) binding, where you specify one "
|
||||||
"class \"T\" but then bind member methods from a complete unrelated class. Check things over!");
|
"class \"T\" but then bind member methods from a complete unrelated class. Check things over!");
|
||||||
#if SOL_IS_ON(SOL_SAFE_USERTYPE_I_)
|
#if SOL_IS_ON(SOL_SAFE_USERTYPE)
|
||||||
auto maybeo = stack::check_get<Ta*>(L, 1);
|
stack::record tracking {};
|
||||||
|
auto maybeo = stack::stack_detail::check_get_arg<Ta*>(L, 1, &no_panic, tracking);
|
||||||
if (!maybeo || maybeo.value() == nullptr) {
|
if (!maybeo || maybeo.value() == nullptr) {
|
||||||
if (is_variable) {
|
if (is_variable) {
|
||||||
return luaL_error(L, "sol: 'self' argument is lua_nil (bad '.' access?)");
|
return luaL_error(L, "sol: 'self' argument is lua_nil (bad '.' access?)");
|
||||||
|
|
@ -573,8 +575,9 @@ namespace sol {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
using Ta = meta::conditional_t<std::is_void_v<T>, object_type, T>;
|
using Ta = meta::conditional_t<std::is_void_v<T>, object_type, T>;
|
||||||
#if SOL_IS_ON(SOL_SAFE_USERTYPE_I_)
|
#if SOL_IS_ON(SOL_SAFE_USERTYPE)
|
||||||
auto maybeo = stack::check_get<Ta*>(L, 1);
|
stack::record tracking {};
|
||||||
|
auto maybeo = stack::stack_detail::check_get_arg<Ta*>(L, 1, &no_panic, tracking);
|
||||||
if (!maybeo || maybeo.value() == nullptr) {
|
if (!maybeo || maybeo.value() == nullptr) {
|
||||||
if (is_variable) {
|
if (is_variable) {
|
||||||
return luaL_error(L, "sol: received nil for 'self' argument (bad '.' access?)");
|
return luaL_error(L, "sol: received nil for 'self' argument (bad '.' access?)");
|
||||||
|
|
@ -811,8 +814,9 @@ namespace sol {
|
||||||
using args_list = meta::pop_front_type_t<typename traits_type::free_args_list>;
|
using args_list = meta::pop_front_type_t<typename traits_type::free_args_list>;
|
||||||
using Ta = T;
|
using Ta = T;
|
||||||
using Oa = std::remove_pointer_t<object_type>;
|
using Oa = std::remove_pointer_t<object_type>;
|
||||||
#if SOL_IS_ON(SOL_SAFE_USERTYPE_I_)
|
#if SOL_IS_ON(SOL_SAFE_USERTYPE)
|
||||||
auto maybeo = stack::check_get<Ta*>(L, 1);
|
stack::record tracking {};
|
||||||
|
auto maybeo = stack::stack_detail::check_get_arg<Ta*>(L, 1, &no_panic, tracking);
|
||||||
if (!maybeo || maybeo.value() == nullptr) {
|
if (!maybeo || maybeo.value() == nullptr) {
|
||||||
if (is_variable) {
|
if (is_variable) {
|
||||||
return luaL_error(L, "sol: 'self' argument is lua_nil (bad '.' access?)");
|
return luaL_error(L, "sol: 'self' argument is lua_nil (bad '.' access?)");
|
||||||
|
|
|
||||||
26
extern/sol3/sol/compatibility.hpp
vendored
26
extern/sol3/sol/compatibility.hpp
vendored
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
// The MIT License (MIT)
|
// The MIT License (MIT)
|
||||||
|
|
||||||
// Copyright (c) 2013-2021 Rapptz, ThePhD and contributors
|
// Copyright (c) 2013-2022 Rapptz, ThePhD and contributors
|
||||||
|
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
// this software and associated documentation files (the "Software"), to deal in
|
// this software and associated documentation files (the "Software"), to deal in
|
||||||
|
|
@ -32,20 +32,20 @@
|
||||||
#include <sol/version.hpp>
|
#include <sol/version.hpp>
|
||||||
#include <sol/compatibility/lua_version.hpp>
|
#include <sol/compatibility/lua_version.hpp>
|
||||||
|
|
||||||
#if SOL_IS_ON(SOL_USE_COMPATIBILITY_LAYER_I_)
|
#if SOL_IS_ON(SOL_USE_COMPATIBILITY_LAYER)
|
||||||
|
|
||||||
#if SOL_IS_ON(SOL_USE_CXX_LUA_I_) || SOL_IS_ON(SOL_USE_CXX_LUAJIT_I_)
|
// clang-format off
|
||||||
#ifndef COMPAT53_LUA_CPP
|
#if SOL_IS_ON(SOL_USING_CXX_LUA) || SOL_IS_ON(SOL_USING_CXX_LUAJIT)
|
||||||
#define COMPAT53_LUA_CPP 1
|
#ifndef COMPAT53_LUA_CPP
|
||||||
#endif // Build Lua Compat layer as C++
|
#define COMPAT53_LUA_CPP 1
|
||||||
|
#endif // Build Lua Compat layer as C++
|
||||||
#endif
|
#endif
|
||||||
#ifndef COMPAT53_INCLUDE_SOURCE
|
#ifndef COMPAT53_INCLUDE_SOURCE
|
||||||
#define COMPAT53_INCLUDE_SOURCE 1
|
#define COMPAT53_INCLUDE_SOURCE 1
|
||||||
#endif // Build Compat Layer Inline
|
#endif // Build Compat Layer Inline
|
||||||
|
#include <sol/compatibility/compat-5.3.h>
|
||||||
#include <sol/compatibility/compat-5.3.h>
|
#include <sol/compatibility/compat-5.4.h>
|
||||||
#include <sol/compatibility/compat-5.4.h>
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
// clang-format on
|
||||||
|
|
||||||
#endif // SOL_COMPATIBILITY_HPP
|
#endif // SOL_COMPATIBILITY_HPP
|
||||||
|
|
|
||||||
1800
extern/sol3/sol/compatibility/compat-5.3.c.h
vendored
1800
extern/sol3/sol/compatibility/compat-5.3.c.h
vendored
File diff suppressed because it is too large
Load diff
854
extern/sol3/sol/compatibility/compat-5.3.h
vendored
854
extern/sol3/sol/compatibility/compat-5.3.h
vendored
|
|
@ -1,424 +1,430 @@
|
||||||
#ifndef KEPLER_PROJECT_COMPAT53_H_
|
#ifndef KEPLER_PROJECT_COMPAT53_H_
|
||||||
#define KEPLER_PROJECT_COMPAT53_H_
|
#define KEPLER_PROJECT_COMPAT53_H_
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#if defined(__cplusplus) && !defined(COMPAT53_LUA_CPP)
|
#if defined(__cplusplus) && !defined(COMPAT53_LUA_CPP)
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
#include <lua.h>
|
#if __has_include(<lua/lua.h>)
|
||||||
#include <lauxlib.h>
|
#include <lua/lua.h>
|
||||||
#include <lualib.h>
|
#include <lua/lauxlib.h>
|
||||||
#if defined(__cplusplus) && !defined(COMPAT53_LUA_CPP)
|
#include <lua/lualib.h>
|
||||||
}
|
#else
|
||||||
#endif
|
#include <lua.h>
|
||||||
|
#include <lauxlib.h>
|
||||||
#ifndef COMPAT53_PREFIX
|
#include <lualib.h>
|
||||||
/* we chose this name because many other lua bindings / libs have
|
#endif
|
||||||
* their own compatibility layer, and that use the compat53 declaration
|
#if defined(__cplusplus) && !defined(COMPAT53_LUA_CPP)
|
||||||
* frequently, causing all kinds of linker / compiler issues
|
}
|
||||||
*/
|
#endif
|
||||||
# define COMPAT53_PREFIX kp_compat53
|
|
||||||
#endif // COMPAT53_PREFIX
|
#ifndef COMPAT53_PREFIX
|
||||||
|
/* we chose this name because many other lua bindings / libs have
|
||||||
#ifndef COMPAT53_API
|
* their own compatibility layer, and that use the compat53 declaration
|
||||||
# if defined(COMPAT53_INCLUDE_SOURCE) && COMPAT53_INCLUDE_SOURCE
|
* frequently, causing all kinds of linker / compiler issues
|
||||||
# if defined(__GNUC__) || defined(__clang__)
|
*/
|
||||||
# define COMPAT53_API __attribute__((__unused__)) static inline
|
# define COMPAT53_PREFIX kp_compat53
|
||||||
# else
|
#endif // COMPAT53_PREFIX
|
||||||
# define COMPAT53_API static inline
|
|
||||||
# endif /* Clang/GCC */
|
#ifndef COMPAT53_API
|
||||||
# else /* COMPAT53_INCLUDE_SOURCE */
|
# if defined(COMPAT53_INCLUDE_SOURCE) && COMPAT53_INCLUDE_SOURCE
|
||||||
/* we are not including source, so everything is extern */
|
# if defined(__GNUC__) || defined(__clang__)
|
||||||
# define COMPAT53_API extern
|
# define COMPAT53_API __attribute__((__unused__)) static inline
|
||||||
# endif /* COMPAT53_INCLUDE_SOURCE */
|
# else
|
||||||
#endif /* COMPAT53_PREFIX */
|
# define COMPAT53_API static inline
|
||||||
|
# endif /* Clang/GCC */
|
||||||
|
# else /* COMPAT53_INCLUDE_SOURCE */
|
||||||
#define COMPAT53_CONCAT_HELPER(a, b) a##b
|
/* we are not including source, so everything is extern */
|
||||||
#define COMPAT53_CONCAT(a, b) COMPAT53_CONCAT_HELPER(a, b)
|
# define COMPAT53_API extern
|
||||||
|
# endif /* COMPAT53_INCLUDE_SOURCE */
|
||||||
|
#endif /* COMPAT53_PREFIX */
|
||||||
|
|
||||||
/* declarations for Lua 5.1 */
|
|
||||||
#if defined(LUA_VERSION_NUM) && LUA_VERSION_NUM == 501
|
#define COMPAT53_CONCAT_HELPER(a, b) a##b
|
||||||
|
#define COMPAT53_CONCAT(a, b) COMPAT53_CONCAT_HELPER(a, b)
|
||||||
/* XXX not implemented:
|
|
||||||
* lua_arith (new operators)
|
|
||||||
* lua_upvalueid
|
|
||||||
* lua_upvaluejoin
|
/* declarations for Lua 5.1 */
|
||||||
* lua_version
|
#if defined(LUA_VERSION_NUM) && LUA_VERSION_NUM == 501
|
||||||
* lua_yieldk
|
|
||||||
*/
|
/* XXX not implemented:
|
||||||
|
* lua_arith (new operators)
|
||||||
#ifndef LUA_OK
|
* lua_upvalueid
|
||||||
# define LUA_OK 0
|
* lua_upvaluejoin
|
||||||
#endif
|
* lua_version
|
||||||
#ifndef LUA_OPADD
|
* lua_yieldk
|
||||||
# define LUA_OPADD 0
|
*/
|
||||||
#endif
|
|
||||||
#ifndef LUA_OPSUB
|
#ifndef LUA_OK
|
||||||
# define LUA_OPSUB 1
|
# define LUA_OK 0
|
||||||
#endif
|
#endif
|
||||||
#ifndef LUA_OPMUL
|
#ifndef LUA_OPADD
|
||||||
# define LUA_OPMUL 2
|
# define LUA_OPADD 0
|
||||||
#endif
|
#endif
|
||||||
#ifndef LUA_OPDIV
|
#ifndef LUA_OPSUB
|
||||||
# define LUA_OPDIV 3
|
# define LUA_OPSUB 1
|
||||||
#endif
|
#endif
|
||||||
#ifndef LUA_OPMOD
|
#ifndef LUA_OPMUL
|
||||||
# define LUA_OPMOD 4
|
# define LUA_OPMUL 2
|
||||||
#endif
|
#endif
|
||||||
#ifndef LUA_OPPOW
|
#ifndef LUA_OPDIV
|
||||||
# define LUA_OPPOW 5
|
# define LUA_OPDIV 3
|
||||||
#endif
|
#endif
|
||||||
#ifndef LUA_OPUNM
|
#ifndef LUA_OPMOD
|
||||||
# define LUA_OPUNM 6
|
# define LUA_OPMOD 4
|
||||||
#endif
|
#endif
|
||||||
#ifndef LUA_OPEQ
|
#ifndef LUA_OPPOW
|
||||||
# define LUA_OPEQ 0
|
# define LUA_OPPOW 5
|
||||||
#endif
|
#endif
|
||||||
#ifndef LUA_OPLT
|
#ifndef LUA_OPUNM
|
||||||
# define LUA_OPLT 1
|
# define LUA_OPUNM 6
|
||||||
#endif
|
#endif
|
||||||
#ifndef LUA_OPLE
|
#ifndef LUA_OPEQ
|
||||||
# define LUA_OPLE 2
|
# define LUA_OPEQ 0
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef LUA_OPLT
|
||||||
/* LuaJIT/Lua 5.1 does not have the updated
|
# define LUA_OPLT 1
|
||||||
* error codes for thread status/function returns (but some patched versions do)
|
#endif
|
||||||
* define it only if it's not found
|
#ifndef LUA_OPLE
|
||||||
*/
|
# define LUA_OPLE 2
|
||||||
#if !defined(LUA_ERRGCMM)
|
#endif
|
||||||
/* Use + 2 because in some versions of Lua (Lua 5.1)
|
|
||||||
* LUA_ERRFILE is defined as (LUA_ERRERR+1)
|
/* LuaJIT/Lua 5.1 does not have the updated
|
||||||
* so we need to avoid it (LuaJIT might have something at this
|
* error codes for thread status/function returns (but some patched versions do)
|
||||||
* integer value too)
|
* define it only if it's not found
|
||||||
*/
|
*/
|
||||||
# define LUA_ERRGCMM (LUA_ERRERR + 2)
|
#if !defined(LUA_ERRGCMM)
|
||||||
#endif /* LUA_ERRGCMM define */
|
/* Use + 2 because in some versions of Lua (Lua 5.1)
|
||||||
|
* LUA_ERRFILE is defined as (LUA_ERRERR+1)
|
||||||
#if !defined(MOONJIT_VERSION)
|
* so we need to avoid it (LuaJIT might have something at this
|
||||||
typedef size_t lua_Unsigned;
|
* integer value too)
|
||||||
#endif
|
*/
|
||||||
|
# define LUA_ERRGCMM (LUA_ERRERR + 2)
|
||||||
typedef struct luaL_Buffer_53 {
|
#endif /* LUA_ERRGCMM define */
|
||||||
luaL_Buffer b; /* make incorrect code crash! */
|
|
||||||
char *ptr;
|
#if !defined(MOONJIT_VERSION)
|
||||||
size_t nelems;
|
typedef size_t lua_Unsigned;
|
||||||
size_t capacity;
|
#endif
|
||||||
lua_State *L2;
|
|
||||||
} luaL_Buffer_53;
|
typedef struct luaL_Buffer_53 {
|
||||||
#define luaL_Buffer luaL_Buffer_53
|
luaL_Buffer b; /* make incorrect code crash! */
|
||||||
|
char *ptr;
|
||||||
/* In PUC-Rio 5.1, userdata is a simple FILE*
|
size_t nelems;
|
||||||
* In LuaJIT, it's a struct where the first member is a FILE*
|
size_t capacity;
|
||||||
* We can't support the `closef` member
|
lua_State *L2;
|
||||||
*/
|
} luaL_Buffer_53;
|
||||||
typedef struct luaL_Stream {
|
#define luaL_Buffer luaL_Buffer_53
|
||||||
FILE *f;
|
|
||||||
} luaL_Stream;
|
/* In PUC-Rio 5.1, userdata is a simple FILE*
|
||||||
|
* In LuaJIT, it's a struct where the first member is a FILE*
|
||||||
#define lua_absindex COMPAT53_CONCAT(COMPAT53_PREFIX, _absindex)
|
* We can't support the `closef` member
|
||||||
COMPAT53_API int lua_absindex(lua_State *L, int i);
|
*/
|
||||||
|
typedef struct luaL_Stream {
|
||||||
#define lua_arith COMPAT53_CONCAT(COMPAT53_PREFIX, _arith)
|
FILE *f;
|
||||||
COMPAT53_API void lua_arith(lua_State *L, int op);
|
} luaL_Stream;
|
||||||
|
|
||||||
#define lua_compare COMPAT53_CONCAT(COMPAT53_PREFIX, _compare)
|
#define lua_absindex COMPAT53_CONCAT(COMPAT53_PREFIX, _absindex)
|
||||||
COMPAT53_API int lua_compare(lua_State *L, int idx1, int idx2, int op);
|
COMPAT53_API int lua_absindex(lua_State *L, int i);
|
||||||
|
|
||||||
#define lua_copy COMPAT53_CONCAT(COMPAT53_PREFIX, _copy)
|
#define lua_arith COMPAT53_CONCAT(COMPAT53_PREFIX, _arith)
|
||||||
COMPAT53_API void lua_copy(lua_State *L, int from, int to);
|
COMPAT53_API void lua_arith(lua_State *L, int op);
|
||||||
|
|
||||||
#define lua_getuservalue(L, i) \
|
#define lua_compare COMPAT53_CONCAT(COMPAT53_PREFIX, _compare)
|
||||||
(lua_getfenv((L), (i)), lua_type((L), -1))
|
COMPAT53_API int lua_compare(lua_State *L, int idx1, int idx2, int op);
|
||||||
#define lua_setuservalue(L, i) \
|
|
||||||
(luaL_checktype((L), -1, LUA_TTABLE), lua_setfenv((L), (i)))
|
#define lua_copy COMPAT53_CONCAT(COMPAT53_PREFIX, _copy)
|
||||||
|
COMPAT53_API void lua_copy(lua_State *L, int from, int to);
|
||||||
#define lua_len COMPAT53_CONCAT(COMPAT53_PREFIX, _len)
|
|
||||||
COMPAT53_API void lua_len(lua_State *L, int i);
|
#define lua_getuservalue(L, i) \
|
||||||
|
(lua_getfenv((L), (i)), lua_type((L), -1))
|
||||||
#define lua_pushstring(L, s) \
|
#define lua_setuservalue(L, i) \
|
||||||
(lua_pushstring((L), (s)), lua_tostring((L), -1))
|
(luaL_checktype((L), -1, LUA_TTABLE), lua_setfenv((L), (i)))
|
||||||
|
|
||||||
#define lua_pushlstring(L, s, len) \
|
#define lua_len COMPAT53_CONCAT(COMPAT53_PREFIX, _len)
|
||||||
((((len) == 0) ? lua_pushlstring((L), "", 0) : lua_pushlstring((L), (s), (len))), lua_tostring((L), -1))
|
COMPAT53_API void lua_len(lua_State *L, int i);
|
||||||
|
|
||||||
#ifndef luaL_newlibtable
|
#define lua_pushstring(L, s) \
|
||||||
# define luaL_newlibtable(L, l) \
|
(lua_pushstring((L), (s)), lua_tostring((L), -1))
|
||||||
(lua_createtable((L), 0, sizeof((l))/sizeof(*(l))-1))
|
|
||||||
#endif
|
#define lua_pushlstring(L, s, len) \
|
||||||
#ifndef luaL_newlib
|
((((len) == 0) ? lua_pushlstring((L), "", 0) : lua_pushlstring((L), (s), (len))), lua_tostring((L), -1))
|
||||||
# define luaL_newlib(L, l) \
|
|
||||||
(luaL_newlibtable((L), (l)), luaL_register((L), NULL, (l)))
|
#ifndef luaL_newlibtable
|
||||||
#endif
|
# define luaL_newlibtable(L, l) \
|
||||||
|
(lua_createtable((L), 0, sizeof((l))/sizeof(*(l))-1))
|
||||||
#ifndef lua_pushglobaltable
|
#endif
|
||||||
# define lua_pushglobaltable(L) \
|
#ifndef luaL_newlib
|
||||||
lua_pushvalue((L), LUA_GLOBALSINDEX)
|
# define luaL_newlib(L, l) \
|
||||||
#endif
|
(luaL_newlibtable((L), (l)), luaL_register((L), NULL, (l)))
|
||||||
#define lua_rawgetp COMPAT53_CONCAT(COMPAT53_PREFIX, _rawgetp)
|
#endif
|
||||||
COMPAT53_API int lua_rawgetp(lua_State *L, int i, const void *p);
|
|
||||||
|
#ifndef lua_pushglobaltable
|
||||||
#define lua_rawsetp COMPAT53_CONCAT(COMPAT53_PREFIX, _rawsetp)
|
# define lua_pushglobaltable(L) \
|
||||||
COMPAT53_API void lua_rawsetp(lua_State *L, int i, const void *p);
|
lua_pushvalue((L), LUA_GLOBALSINDEX)
|
||||||
|
#endif
|
||||||
#define lua_rawlen(L, i) lua_objlen((L), (i))
|
#define lua_rawgetp COMPAT53_CONCAT(COMPAT53_PREFIX, _rawgetp)
|
||||||
|
COMPAT53_API int lua_rawgetp(lua_State *L, int i, const void *p);
|
||||||
#define lua_tointeger(L, i) lua_tointegerx((L), (i), NULL)
|
|
||||||
|
#define lua_rawsetp COMPAT53_CONCAT(COMPAT53_PREFIX, _rawsetp)
|
||||||
#define lua_tonumberx COMPAT53_CONCAT(COMPAT53_PREFIX, _tonumberx)
|
COMPAT53_API void lua_rawsetp(lua_State *L, int i, const void *p);
|
||||||
COMPAT53_API lua_Number lua_tonumberx(lua_State *L, int i, int *isnum);
|
|
||||||
|
#define lua_rawlen(L, i) lua_objlen((L), (i))
|
||||||
#define luaL_checkversion COMPAT53_CONCAT(COMPAT53_PREFIX, L_checkversion)
|
|
||||||
COMPAT53_API void luaL_checkversion(lua_State *L);
|
#define lua_tointeger(L, i) lua_tointegerx((L), (i), NULL)
|
||||||
|
|
||||||
#define lua_load COMPAT53_CONCAT(COMPAT53_PREFIX, _load_53)
|
#define lua_tonumberx COMPAT53_CONCAT(COMPAT53_PREFIX, _tonumberx)
|
||||||
COMPAT53_API int lua_load(lua_State *L, lua_Reader reader, void *data, const char* source, const char* mode);
|
COMPAT53_API lua_Number lua_tonumberx(lua_State *L, int i, int *isnum);
|
||||||
|
|
||||||
#define luaL_loadfilex COMPAT53_CONCAT(COMPAT53_PREFIX, L_loadfilex)
|
#define luaL_checkversion COMPAT53_CONCAT(COMPAT53_PREFIX, L_checkversion)
|
||||||
COMPAT53_API int luaL_loadfilex(lua_State *L, const char *filename, const char *mode);
|
COMPAT53_API void luaL_checkversion(lua_State *L);
|
||||||
|
|
||||||
#define luaL_loadbufferx COMPAT53_CONCAT(COMPAT53_PREFIX, L_loadbufferx)
|
#define lua_load COMPAT53_CONCAT(COMPAT53_PREFIX, _load_53)
|
||||||
COMPAT53_API int luaL_loadbufferx(lua_State *L, const char *buff, size_t sz, const char *name, const char *mode);
|
COMPAT53_API int lua_load(lua_State *L, lua_Reader reader, void *data, const char* source, const char* mode);
|
||||||
|
|
||||||
#define luaL_checkstack COMPAT53_CONCAT(COMPAT53_PREFIX, L_checkstack_53)
|
#define luaL_loadfilex COMPAT53_CONCAT(COMPAT53_PREFIX, L_loadfilex)
|
||||||
COMPAT53_API void luaL_checkstack(lua_State *L, int sp, const char *msg);
|
COMPAT53_API int luaL_loadfilex(lua_State *L, const char *filename, const char *mode);
|
||||||
|
|
||||||
#define luaL_getsubtable COMPAT53_CONCAT(COMPAT53_PREFIX, L_getsubtable)
|
#define luaL_loadbufferx COMPAT53_CONCAT(COMPAT53_PREFIX, L_loadbufferx)
|
||||||
COMPAT53_API int luaL_getsubtable(lua_State* L, int i, const char *name);
|
COMPAT53_API int luaL_loadbufferx(lua_State *L, const char *buff, size_t sz, const char *name, const char *mode);
|
||||||
|
|
||||||
#define luaL_len COMPAT53_CONCAT(COMPAT53_PREFIX, L_len)
|
#define luaL_checkstack COMPAT53_CONCAT(COMPAT53_PREFIX, L_checkstack_53)
|
||||||
COMPAT53_API lua_Integer luaL_len(lua_State *L, int i);
|
COMPAT53_API void luaL_checkstack(lua_State *L, int sp, const char *msg);
|
||||||
|
|
||||||
#define luaL_setfuncs COMPAT53_CONCAT(COMPAT53_PREFIX, L_setfuncs)
|
#define luaL_getsubtable COMPAT53_CONCAT(COMPAT53_PREFIX, L_getsubtable)
|
||||||
COMPAT53_API void luaL_setfuncs(lua_State *L, const luaL_Reg *l, int nup);
|
COMPAT53_API int luaL_getsubtable(lua_State* L, int i, const char *name);
|
||||||
|
|
||||||
#define luaL_setmetatable COMPAT53_CONCAT(COMPAT53_PREFIX, L_setmetatable)
|
#define luaL_len COMPAT53_CONCAT(COMPAT53_PREFIX, L_len)
|
||||||
COMPAT53_API void luaL_setmetatable(lua_State *L, const char *tname);
|
COMPAT53_API lua_Integer luaL_len(lua_State *L, int i);
|
||||||
|
|
||||||
#define luaL_testudata COMPAT53_CONCAT(COMPAT53_PREFIX, L_testudata)
|
#define luaL_setfuncs COMPAT53_CONCAT(COMPAT53_PREFIX, L_setfuncs)
|
||||||
COMPAT53_API void *luaL_testudata(lua_State *L, int i, const char *tname);
|
COMPAT53_API void luaL_setfuncs(lua_State *L, const luaL_Reg *l, int nup);
|
||||||
|
|
||||||
#define luaL_traceback COMPAT53_CONCAT(COMPAT53_PREFIX, L_traceback)
|
#define luaL_setmetatable COMPAT53_CONCAT(COMPAT53_PREFIX, L_setmetatable)
|
||||||
COMPAT53_API void luaL_traceback(lua_State *L, lua_State *L1, const char *msg, int level);
|
COMPAT53_API void luaL_setmetatable(lua_State *L, const char *tname);
|
||||||
|
|
||||||
#define luaL_fileresult COMPAT53_CONCAT(COMPAT53_PREFIX, L_fileresult)
|
#define luaL_testudata COMPAT53_CONCAT(COMPAT53_PREFIX, L_testudata)
|
||||||
COMPAT53_API int luaL_fileresult(lua_State *L, int stat, const char *fname);
|
COMPAT53_API void *luaL_testudata(lua_State *L, int i, const char *tname);
|
||||||
|
|
||||||
#define luaL_execresult COMPAT53_CONCAT(COMPAT53_PREFIX, L_execresult)
|
#define luaL_traceback COMPAT53_CONCAT(COMPAT53_PREFIX, L_traceback)
|
||||||
COMPAT53_API int luaL_execresult(lua_State *L, int stat);
|
COMPAT53_API void luaL_traceback(lua_State *L, lua_State *L1, const char *msg, int level);
|
||||||
|
|
||||||
#define lua_callk(L, na, nr, ctx, cont) \
|
#define luaL_fileresult COMPAT53_CONCAT(COMPAT53_PREFIX, L_fileresult)
|
||||||
((void)(ctx), (void)(cont), lua_call((L), (na), (nr)))
|
COMPAT53_API int luaL_fileresult(lua_State *L, int stat, const char *fname);
|
||||||
#define lua_pcallk(L, na, nr, err, ctx, cont) \
|
|
||||||
((void)(ctx), (void)(cont), lua_pcall((L), (na), (nr), (err)))
|
#define luaL_execresult COMPAT53_CONCAT(COMPAT53_PREFIX, L_execresult)
|
||||||
|
COMPAT53_API int luaL_execresult(lua_State *L, int stat);
|
||||||
#define lua_resume(L, from, nargs) \
|
|
||||||
((void)(from), lua_resume((L), (nargs)))
|
#define lua_callk(L, na, nr, ctx, cont) \
|
||||||
|
((void)(ctx), (void)(cont), lua_call((L), (na), (nr)))
|
||||||
#define luaL_buffinit COMPAT53_CONCAT(COMPAT53_PREFIX, _buffinit_53)
|
#define lua_pcallk(L, na, nr, err, ctx, cont) \
|
||||||
COMPAT53_API void luaL_buffinit(lua_State *L, luaL_Buffer_53 *B);
|
((void)(ctx), (void)(cont), lua_pcall((L), (na), (nr), (err)))
|
||||||
|
|
||||||
#define luaL_prepbuffsize COMPAT53_CONCAT(COMPAT53_PREFIX, _prepbufsize_53)
|
#define lua_resume(L, from, nargs) \
|
||||||
COMPAT53_API char *luaL_prepbuffsize(luaL_Buffer_53 *B, size_t s);
|
((void)(from), lua_resume((L), (nargs)))
|
||||||
|
|
||||||
#define luaL_addlstring COMPAT53_CONCAT(COMPAT53_PREFIX, _addlstring_53)
|
#define luaL_buffinit COMPAT53_CONCAT(COMPAT53_PREFIX, _buffinit_53)
|
||||||
COMPAT53_API void luaL_addlstring(luaL_Buffer_53 *B, const char *s, size_t l);
|
COMPAT53_API void luaL_buffinit(lua_State *L, luaL_Buffer_53 *B);
|
||||||
|
|
||||||
#define luaL_addvalue COMPAT53_CONCAT(COMPAT53_PREFIX, _addvalue_53)
|
#define luaL_prepbuffsize COMPAT53_CONCAT(COMPAT53_PREFIX, _prepbufsize_53)
|
||||||
COMPAT53_API void luaL_addvalue(luaL_Buffer_53 *B);
|
COMPAT53_API char *luaL_prepbuffsize(luaL_Buffer_53 *B, size_t s);
|
||||||
|
|
||||||
#define luaL_pushresult COMPAT53_CONCAT(COMPAT53_PREFIX, _pushresult_53)
|
#define luaL_addlstring COMPAT53_CONCAT(COMPAT53_PREFIX, _addlstring_53)
|
||||||
COMPAT53_API void luaL_pushresult(luaL_Buffer_53 *B);
|
COMPAT53_API void luaL_addlstring(luaL_Buffer_53 *B, const char *s, size_t l);
|
||||||
|
|
||||||
#undef luaL_buffinitsize
|
#define luaL_addvalue COMPAT53_CONCAT(COMPAT53_PREFIX, _addvalue_53)
|
||||||
#define luaL_buffinitsize(L, B, s) \
|
COMPAT53_API void luaL_addvalue(luaL_Buffer_53 *B);
|
||||||
(luaL_buffinit((L), (B)), luaL_prepbuffsize((B), (s)))
|
|
||||||
|
#define luaL_pushresult COMPAT53_CONCAT(COMPAT53_PREFIX, _pushresult_53)
|
||||||
#undef luaL_prepbuffer
|
COMPAT53_API void luaL_pushresult(luaL_Buffer_53 *B);
|
||||||
#define luaL_prepbuffer(B) \
|
|
||||||
luaL_prepbuffsize((B), LUAL_BUFFERSIZE)
|
#undef luaL_buffinitsize
|
||||||
|
#define luaL_buffinitsize(L, B, s) \
|
||||||
#undef luaL_addchar
|
(luaL_buffinit((L), (B)), luaL_prepbuffsize((B), (s)))
|
||||||
#define luaL_addchar(B, c) \
|
|
||||||
((void)((B)->nelems < (B)->capacity || luaL_prepbuffsize((B), 1)), \
|
#undef luaL_prepbuffer
|
||||||
((B)->ptr[(B)->nelems++] = (c)))
|
#define luaL_prepbuffer(B) \
|
||||||
|
luaL_prepbuffsize((B), LUAL_BUFFERSIZE)
|
||||||
#undef luaL_addsize
|
|
||||||
#define luaL_addsize(B, s) \
|
#undef luaL_addchar
|
||||||
((B)->nelems += (s))
|
#define luaL_addchar(B, c) \
|
||||||
|
((void)((B)->nelems < (B)->capacity || luaL_prepbuffsize((B), 1)), \
|
||||||
#undef luaL_addstring
|
((B)->ptr[(B)->nelems++] = (c)))
|
||||||
#define luaL_addstring(B, s) \
|
|
||||||
luaL_addlstring((B), (s), strlen((s)))
|
#undef luaL_addsize
|
||||||
|
#define luaL_addsize(B, s) \
|
||||||
#undef luaL_pushresultsize
|
((B)->nelems += (s))
|
||||||
#define luaL_pushresultsize(B, s) \
|
|
||||||
(luaL_addsize((B), (s)), luaL_pushresult((B)))
|
#undef luaL_addstring
|
||||||
|
#define luaL_addstring(B, s) \
|
||||||
#if defined(LUA_COMPAT_APIINTCASTS)
|
luaL_addlstring((B), (s), strlen((s)))
|
||||||
#define lua_pushunsigned(L, n) \
|
|
||||||
lua_pushinteger((L), (lua_Integer)(n))
|
#undef luaL_pushresultsize
|
||||||
#define lua_tounsignedx(L, i, is) \
|
#define luaL_pushresultsize(B, s) \
|
||||||
((lua_Unsigned)lua_tointegerx((L), (i), (is)))
|
(luaL_addsize((B), (s)), luaL_pushresult((B)))
|
||||||
#define lua_tounsigned(L, i) \
|
|
||||||
lua_tounsignedx((L), (i), NULL)
|
#if defined(LUA_COMPAT_APIINTCASTS)
|
||||||
#define luaL_checkunsigned(L, a) \
|
#define lua_pushunsigned(L, n) \
|
||||||
((lua_Unsigned)luaL_checkinteger((L), (a)))
|
lua_pushinteger((L), (lua_Integer)(n))
|
||||||
#define luaL_optunsigned(L, a, d) \
|
#define lua_tounsignedx(L, i, is) \
|
||||||
((lua_Unsigned)luaL_optinteger((L), (a), (lua_Integer)(d)))
|
((lua_Unsigned)lua_tointegerx((L), (i), (is)))
|
||||||
#endif
|
#define lua_tounsigned(L, i) \
|
||||||
|
lua_tounsignedx((L), (i), NULL)
|
||||||
#endif /* Lua 5.1 only */
|
#define luaL_checkunsigned(L, a) \
|
||||||
|
((lua_Unsigned)luaL_checkinteger((L), (a)))
|
||||||
|
#define luaL_optunsigned(L, a, d) \
|
||||||
|
((lua_Unsigned)luaL_optinteger((L), (a), (lua_Integer)(d)))
|
||||||
/* declarations for Lua 5.1 and 5.2 */
|
#endif
|
||||||
#if defined(LUA_VERSION_NUM) && LUA_VERSION_NUM <= 502
|
|
||||||
|
#endif /* Lua 5.1 only */
|
||||||
typedef int lua_KContext;
|
|
||||||
|
|
||||||
typedef int(*lua_KFunction)(lua_State *L, int status, lua_KContext ctx);
|
|
||||||
|
/* declarations for Lua 5.1 and 5.2 */
|
||||||
#define lua_dump(L, w, d, s) \
|
#if defined(LUA_VERSION_NUM) && LUA_VERSION_NUM <= 502
|
||||||
((void)(s), lua_dump((L), (w), (d)))
|
|
||||||
|
typedef int lua_KContext;
|
||||||
#define lua_getfield(L, i, k) \
|
|
||||||
(lua_getfield((L), (i), (k)), lua_type((L), -1))
|
typedef int(*lua_KFunction)(lua_State *L, int status, lua_KContext ctx);
|
||||||
|
|
||||||
#define lua_gettable(L, i) \
|
#define lua_dump(L, w, d, s) \
|
||||||
(lua_gettable((L), (i)), lua_type((L), -1))
|
((void)(s), lua_dump((L), (w), (d)))
|
||||||
|
|
||||||
#define lua_geti COMPAT53_CONCAT(COMPAT53_PREFIX, _geti)
|
#define lua_getfield(L, i, k) \
|
||||||
COMPAT53_API int lua_geti(lua_State *L, int index, lua_Integer i);
|
(lua_getfield((L), (i), (k)), lua_type((L), -1))
|
||||||
|
|
||||||
#define lua_isinteger COMPAT53_CONCAT(COMPAT53_PREFIX, _isinteger)
|
#define lua_gettable(L, i) \
|
||||||
COMPAT53_API int lua_isinteger(lua_State *L, int index);
|
(lua_gettable((L), (i)), lua_type((L), -1))
|
||||||
|
|
||||||
#define lua_tointegerx COMPAT53_CONCAT(COMPAT53_PREFIX, _tointegerx_53)
|
#define lua_geti COMPAT53_CONCAT(COMPAT53_PREFIX, _geti)
|
||||||
COMPAT53_API lua_Integer lua_tointegerx(lua_State *L, int i, int *isnum);
|
COMPAT53_API int lua_geti(lua_State *L, int index, lua_Integer i);
|
||||||
|
|
||||||
#define lua_numbertointeger(n, p) \
|
#define lua_isinteger COMPAT53_CONCAT(COMPAT53_PREFIX, _isinteger)
|
||||||
((*(p) = (lua_Integer)(n)), 1)
|
COMPAT53_API int lua_isinteger(lua_State *L, int index);
|
||||||
|
|
||||||
#define lua_rawget(L, i) \
|
#define lua_tointegerx COMPAT53_CONCAT(COMPAT53_PREFIX, _tointegerx_53)
|
||||||
(lua_rawget((L), (i)), lua_type((L), -1))
|
COMPAT53_API lua_Integer lua_tointegerx(lua_State *L, int i, int *isnum);
|
||||||
|
|
||||||
#define lua_rawgeti(L, i, n) \
|
#define lua_numbertointeger(n, p) \
|
||||||
(lua_rawgeti((L), (i), (n)), lua_type((L), -1))
|
((*(p) = (lua_Integer)(n)), 1)
|
||||||
|
|
||||||
#define lua_rotate COMPAT53_CONCAT(COMPAT53_PREFIX, _rotate)
|
#define lua_rawget(L, i) \
|
||||||
COMPAT53_API void lua_rotate(lua_State *L, int idx, int n);
|
(lua_rawget((L), (i)), lua_type((L), -1))
|
||||||
|
|
||||||
#define lua_seti COMPAT53_CONCAT(COMPAT53_PREFIX, _seti)
|
#define lua_rawgeti(L, i, n) \
|
||||||
COMPAT53_API void lua_seti(lua_State *L, int index, lua_Integer i);
|
(lua_rawgeti((L), (i), (n)), lua_type((L), -1))
|
||||||
|
|
||||||
#define lua_stringtonumber COMPAT53_CONCAT(COMPAT53_PREFIX, _stringtonumber)
|
#define lua_rotate COMPAT53_CONCAT(COMPAT53_PREFIX, _rotate)
|
||||||
COMPAT53_API size_t lua_stringtonumber(lua_State *L, const char *s);
|
COMPAT53_API void lua_rotate(lua_State *L, int idx, int n);
|
||||||
|
|
||||||
#define luaL_tolstring COMPAT53_CONCAT(COMPAT53_PREFIX, L_tolstring)
|
#define lua_seti COMPAT53_CONCAT(COMPAT53_PREFIX, _seti)
|
||||||
COMPAT53_API const char *luaL_tolstring(lua_State *L, int idx, size_t *len);
|
COMPAT53_API void lua_seti(lua_State *L, int index, lua_Integer i);
|
||||||
|
|
||||||
#define luaL_getmetafield(L, o, e) \
|
#define lua_stringtonumber COMPAT53_CONCAT(COMPAT53_PREFIX, _stringtonumber)
|
||||||
(luaL_getmetafield((L), (o), (e)) ? lua_type((L), -1) : LUA_TNIL)
|
COMPAT53_API size_t lua_stringtonumber(lua_State *L, const char *s);
|
||||||
|
|
||||||
#define luaL_newmetatable(L, tn) \
|
#define luaL_tolstring COMPAT53_CONCAT(COMPAT53_PREFIX, L_tolstring)
|
||||||
(luaL_newmetatable((L), (tn)) ? (lua_pushstring((L), (tn)), lua_setfield((L), -2, "__name"), 1) : 0)
|
COMPAT53_API const char *luaL_tolstring(lua_State *L, int idx, size_t *len);
|
||||||
|
|
||||||
#define luaL_requiref COMPAT53_CONCAT(COMPAT53_PREFIX, L_requiref_53)
|
#define luaL_getmetafield(L, o, e) \
|
||||||
COMPAT53_API void luaL_requiref(lua_State *L, const char *modname,
|
(luaL_getmetafield((L), (o), (e)) ? lua_type((L), -1) : LUA_TNIL)
|
||||||
lua_CFunction openf, int glb);
|
|
||||||
|
#define luaL_newmetatable(L, tn) \
|
||||||
#endif /* Lua 5.1 and Lua 5.2 */
|
(luaL_newmetatable((L), (tn)) ? (lua_pushstring((L), (tn)), lua_setfield((L), -2, "__name"), 1) : 0)
|
||||||
|
|
||||||
|
#define luaL_requiref COMPAT53_CONCAT(COMPAT53_PREFIX, L_requiref_53)
|
||||||
|
COMPAT53_API void luaL_requiref(lua_State *L, const char *modname,
|
||||||
/* declarations for Lua 5.2 */
|
lua_CFunction openf, int glb);
|
||||||
#if defined(LUA_VERSION_NUM) && LUA_VERSION_NUM == 502
|
|
||||||
|
#endif /* Lua 5.1 and Lua 5.2 */
|
||||||
/* XXX not implemented:
|
|
||||||
* lua_isyieldable
|
|
||||||
* lua_getextraspace
|
|
||||||
* lua_arith (new operators)
|
/* declarations for Lua 5.2 */
|
||||||
* lua_pushfstring (new formats)
|
#if defined(LUA_VERSION_NUM) && LUA_VERSION_NUM == 502
|
||||||
*/
|
|
||||||
|
/* XXX not implemented:
|
||||||
#define lua_getglobal(L, n) \
|
* lua_isyieldable
|
||||||
(lua_getglobal((L), (n)), lua_type((L), -1))
|
* lua_getextraspace
|
||||||
|
* lua_arith (new operators)
|
||||||
#define lua_getuservalue(L, i) \
|
* lua_pushfstring (new formats)
|
||||||
(lua_getuservalue((L), (i)), lua_type((L), -1))
|
*/
|
||||||
|
|
||||||
#define lua_pushlstring(L, s, len) \
|
#define lua_getglobal(L, n) \
|
||||||
(((len) == 0) ? lua_pushlstring((L), "", 0) : lua_pushlstring((L), (s), (len)))
|
(lua_getglobal((L), (n)), lua_type((L), -1))
|
||||||
|
|
||||||
#define lua_rawgetp(L, i, p) \
|
#define lua_getuservalue(L, i) \
|
||||||
(lua_rawgetp((L), (i), (p)), lua_type((L), -1))
|
(lua_getuservalue((L), (i)), lua_type((L), -1))
|
||||||
|
|
||||||
#define LUA_KFUNCTION(_name) \
|
#define lua_pushlstring(L, s, len) \
|
||||||
static int (_name)(lua_State *L, int status, lua_KContext ctx); \
|
(((len) == 0) ? lua_pushlstring((L), "", 0) : lua_pushlstring((L), (s), (len)))
|
||||||
static int (_name ## _52)(lua_State *L) { \
|
|
||||||
lua_KContext ctx; \
|
#define lua_rawgetp(L, i, p) \
|
||||||
int status = lua_getctx(L, &ctx); \
|
(lua_rawgetp((L), (i), (p)), lua_type((L), -1))
|
||||||
return (_name)(L, status, ctx); \
|
|
||||||
} \
|
#define LUA_KFUNCTION(_name) \
|
||||||
static int (_name)(lua_State *L, int status, lua_KContext ctx)
|
static int (_name)(lua_State *L, int status, lua_KContext ctx); \
|
||||||
|
static int (_name ## _52)(lua_State *L) { \
|
||||||
#define lua_pcallk(L, na, nr, err, ctx, cont) \
|
lua_KContext ctx; \
|
||||||
lua_pcallk((L), (na), (nr), (err), (ctx), cont ## _52)
|
int status = lua_getctx(L, &ctx); \
|
||||||
|
return (_name)(L, status, ctx); \
|
||||||
#define lua_callk(L, na, nr, ctx, cont) \
|
} \
|
||||||
lua_callk((L), (na), (nr), (ctx), cont ## _52)
|
static int (_name)(lua_State *L, int status, lua_KContext ctx)
|
||||||
|
|
||||||
#define lua_yieldk(L, nr, ctx, cont) \
|
#define lua_pcallk(L, na, nr, err, ctx, cont) \
|
||||||
lua_yieldk((L), (nr), (ctx), cont ## _52)
|
lua_pcallk((L), (na), (nr), (err), (ctx), cont ## _52)
|
||||||
|
|
||||||
#ifdef lua_call
|
#define lua_callk(L, na, nr, ctx, cont) \
|
||||||
# undef lua_call
|
lua_callk((L), (na), (nr), (ctx), cont ## _52)
|
||||||
# define lua_call(L, na, nr) \
|
|
||||||
(lua_callk)((L), (na), (nr), 0, NULL)
|
#define lua_yieldk(L, nr, ctx, cont) \
|
||||||
#endif
|
lua_yieldk((L), (nr), (ctx), cont ## _52)
|
||||||
|
|
||||||
#ifdef lua_pcall
|
#ifdef lua_call
|
||||||
# undef lua_pcall
|
# undef lua_call
|
||||||
# define lua_pcall(L, na, nr, err) \
|
# define lua_call(L, na, nr) \
|
||||||
(lua_pcallk)((L), (na), (nr), (err), 0, NULL)
|
(lua_callk)((L), (na), (nr), 0, NULL)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef lua_yield
|
#ifdef lua_pcall
|
||||||
# undef lua_yield
|
# undef lua_pcall
|
||||||
# define lua_yield(L, nr) \
|
# define lua_pcall(L, na, nr, err) \
|
||||||
(lua_yieldk)((L), (nr), 0, NULL)
|
(lua_pcallk)((L), (na), (nr), (err), 0, NULL)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* Lua 5.2 only */
|
#ifdef lua_yield
|
||||||
|
# undef lua_yield
|
||||||
|
# define lua_yield(L, nr) \
|
||||||
|
(lua_yieldk)((L), (nr), 0, NULL)
|
||||||
/* other Lua versions */
|
#endif
|
||||||
#if !defined(LUA_VERSION_NUM) || LUA_VERSION_NUM < 501 || LUA_VERSION_NUM > 504
|
|
||||||
|
#endif /* Lua 5.2 only */
|
||||||
# error "unsupported Lua version (i.e. not Lua 5.1, 5.2, 5.3, or 5.4)"
|
|
||||||
|
|
||||||
#endif /* other Lua versions except 5.1, 5.2, 5.3, and 5.4 */
|
|
||||||
|
/* other Lua versions */
|
||||||
|
#if !defined(LUA_VERSION_NUM) || LUA_VERSION_NUM < 501 || LUA_VERSION_NUM > 504
|
||||||
|
|
||||||
/* helper macro for defining continuation functions (for every version
|
# error "unsupported Lua version (i.e. not Lua 5.1, 5.2, 5.3, or 5.4)"
|
||||||
* *except* Lua 5.2) */
|
|
||||||
#ifndef LUA_KFUNCTION
|
#endif /* other Lua versions except 5.1, 5.2, 5.3, and 5.4 */
|
||||||
#define LUA_KFUNCTION(_name) \
|
|
||||||
static int (_name)(lua_State *L, int status, lua_KContext ctx)
|
|
||||||
#endif
|
|
||||||
|
/* helper macro for defining continuation functions (for every version
|
||||||
|
* *except* Lua 5.2) */
|
||||||
#if defined(COMPAT53_INCLUDE_SOURCE) && COMPAT53_INCLUDE_SOURCE == 1
|
#ifndef LUA_KFUNCTION
|
||||||
# include "compat-5.3.c.h"
|
#define LUA_KFUNCTION(_name) \
|
||||||
#endif
|
static int (_name)(lua_State *L, int status, lua_KContext ctx)
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* KEPLER_PROJECT_COMPAT53_H_ */
|
|
||||||
|
#if defined(COMPAT53_INCLUDE_SOURCE) && COMPAT53_INCLUDE_SOURCE == 1
|
||||||
|
# include "compat-5.3.c.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* KEPLER_PROJECT_COMPAT53_H_ */
|
||||||
|
|
||||||
|
|
|
||||||
54
extern/sol3/sol/compatibility/compat-5.4.h
vendored
54
extern/sol3/sol/compatibility/compat-5.4.h
vendored
|
|
@ -1,25 +1,31 @@
|
||||||
#ifndef NOT_KEPLER_PROJECT_COMPAT54_H_
|
#ifndef NOT_KEPLER_PROJECT_COMPAT54_H_
|
||||||
#define NOT_KEPLER_PROJECT_COMPAT54_H_
|
#define NOT_KEPLER_PROJECT_COMPAT54_H_
|
||||||
|
|
||||||
#if defined(__cplusplus) && !defined(COMPAT53_LUA_CPP)
|
#if defined(__cplusplus) && !defined(COMPAT53_LUA_CPP)
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
#include <lua.h>
|
#if __has_include(<lua/lua.h>)
|
||||||
#include <lauxlib.h>
|
#include <lua/lua.h>
|
||||||
#include <lualib.h>
|
#include <lua/lauxlib.h>
|
||||||
#if defined(__cplusplus) && !defined(COMPAT53_LUA_CPP)
|
#include <lua/lualib.h>
|
||||||
}
|
#else
|
||||||
#endif
|
#include <lua.h>
|
||||||
|
#include <lauxlib.h>
|
||||||
#if defined(LUA_VERSION_NUM) && LUA_VERSION_NUM == 504
|
#include <lualib.h>
|
||||||
|
#endif
|
||||||
#if !defined(LUA_ERRGCMM)
|
#if defined(__cplusplus) && !defined(COMPAT53_LUA_CPP)
|
||||||
/* So Lua 5.4 actually removes this, which breaks sol2...
|
}
|
||||||
man, this API is quite unstable...!
|
#endif
|
||||||
*/
|
|
||||||
# define LUA_ERRGCMM (LUA_ERRERR + 2)
|
#if defined(LUA_VERSION_NUM) && LUA_VERSION_NUM == 504
|
||||||
#endif /* LUA_ERRGCMM define */
|
|
||||||
|
#if !defined(LUA_ERRGCMM)
|
||||||
#endif // Lua 5.4 only
|
/* So Lua 5.4 actually removes this, which breaks sol2...
|
||||||
|
man, this API is quite unstable...!
|
||||||
|
*/
|
||||||
|
# define LUA_ERRGCMM (LUA_ERRERR + 2)
|
||||||
|
#endif /* LUA_ERRGCMM define */
|
||||||
|
|
||||||
|
#endif // Lua 5.4 only
|
||||||
|
|
||||||
#endif // NOT_KEPLER_PROJECT_COMPAT54_H_
|
#endif // NOT_KEPLER_PROJECT_COMPAT54_H_
|
||||||
99
extern/sol3/sol/compatibility/lua_version.hpp
vendored
99
extern/sol3/sol/compatibility/lua_version.hpp
vendored
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
// The MIT License (MIT)
|
// The MIT License (MIT)
|
||||||
|
|
||||||
// Copyright (c) 2013-2021 Rapptz, ThePhD and contributors
|
// Copyright (c) 2013-2022 Rapptz, ThePhD and contributors
|
||||||
|
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
// this software and associated documentation files (the "Software"), to deal in
|
// this software and associated documentation files (the "Software"), to deal in
|
||||||
|
|
@ -21,24 +21,40 @@
|
||||||
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
#ifndef SOL_COMPATIBILITY_VERSION_HPP
|
#ifndef SOL_COMPATIBILITY_LUA_VERSION_HPP
|
||||||
#define SOL_COMPATIBILITY_VERSION_HPP
|
#define SOL_COMPATIBILITY_LUA_VERSION_HPP
|
||||||
|
|
||||||
#include <sol/version.hpp>
|
#include <sol/version.hpp>
|
||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
|
|
||||||
#if SOL_IS_ON(SOL_USE_CXX_LUA_I_)
|
#if SOL_IS_ON(SOL_USING_CXX_LUA)
|
||||||
#include <lua.h>
|
#if __has_include(<lua/lua.h>)
|
||||||
#include <lualib.h>
|
#include <lua/lua.h>
|
||||||
#include <lauxlib.h>
|
#include <lua/lauxlib.h>
|
||||||
#elif SOL_IS_ON(SOL_USE_LUA_HPP_I_)
|
#include <lua/lualib.h>
|
||||||
#include <lua.hpp>
|
#else
|
||||||
#else
|
|
||||||
extern "C" {
|
|
||||||
#include <lua.h>
|
#include <lua.h>
|
||||||
#include <lauxlib.h>
|
#include <lauxlib.h>
|
||||||
#include <lualib.h>
|
#include <lualib.h>
|
||||||
|
#endif
|
||||||
|
#elif SOL_IS_ON(SOL_USE_LUA_HPP)
|
||||||
|
#if __has_include(<lua/lua.hpp>)
|
||||||
|
#include <lua/lua.hpp>
|
||||||
|
#else
|
||||||
|
#include <lua.hpp>
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
extern "C" {
|
||||||
|
#if __has_include(<lua/lua.h>)
|
||||||
|
#include <lua/lua.h>
|
||||||
|
#include <lua/lauxlib.h>
|
||||||
|
#include <lua/lualib.h>
|
||||||
|
#else
|
||||||
|
#include <lua.h>
|
||||||
|
#include <lauxlib.h>
|
||||||
|
#include <lualib.h>
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
#endif // C++ Mangling for Lua vs. Not
|
#endif // C++ Mangling for Lua vs. Not
|
||||||
|
|
||||||
|
|
@ -50,13 +66,15 @@
|
||||||
#endif
|
#endif
|
||||||
#elif defined(LUAJIT_VERSION)
|
#elif defined(LUAJIT_VERSION)
|
||||||
#define SOL_USE_LUAJIT_I_ SOL_ON
|
#define SOL_USE_LUAJIT_I_ SOL_ON
|
||||||
|
#elif SOL_IS_ON(SOL_USING_CXX_LUAJIT)
|
||||||
|
#define SOL_USE_LUAJIT_I_ SOL_ON
|
||||||
#else
|
#else
|
||||||
#define SOL_USE_LUAJIT_I_ SOL_DEFAULT_OFF
|
#define SOL_USE_LUAJIT_I_ SOL_DEFAULT_OFF
|
||||||
#endif // luajit
|
#endif // luajit
|
||||||
|
|
||||||
#if SOL_IS_ON(SOL_USE_CXX_LUAJIT_I_)
|
#if SOL_IS_ON(SOL_USING_CXX_LUAJIT)
|
||||||
#include <luajit.h>
|
#include <luajit.h>
|
||||||
#elif SOL_IS_ON(SOL_USE_LUAJIT_I_)
|
#elif SOL_IS_ON(SOL_USE_LUAJIT)
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#include <luajit.h>
|
#include <luajit.h>
|
||||||
}
|
}
|
||||||
|
|
@ -64,7 +82,7 @@
|
||||||
|
|
||||||
#if defined(SOL_LUAJIT_VERSION)
|
#if defined(SOL_LUAJIT_VERSION)
|
||||||
#define SOL_LUAJIT_VERSION_I_ SOL_LUAJIT_VERSION
|
#define SOL_LUAJIT_VERSION_I_ SOL_LUAJIT_VERSION
|
||||||
#elif SOL_IS_ON(SOL_USE_LUAJIT_I_)
|
#elif SOL_IS_ON(SOL_USE_LUAJIT)
|
||||||
#define SOL_LUAJIT_VERSION_I_ LUAJIT_VERSION_NUM
|
#define SOL_LUAJIT_VERSION_I_ LUAJIT_VERSION_NUM
|
||||||
#else
|
#else
|
||||||
#define SOL_LUAJIT_VERSION_I_ 0
|
#define SOL_LUAJIT_VERSION_I_ 0
|
||||||
|
|
@ -118,21 +136,25 @@
|
||||||
#else
|
#else
|
||||||
#define SOL_PROPAGATE_EXCEPTIONS_I_ SOL_OFF
|
#define SOL_PROPAGATE_EXCEPTIONS_I_ SOL_OFF
|
||||||
#endif
|
#endif
|
||||||
#elif SOL_LUAJIT_VERSION_I_ >= 20100
|
|
||||||
// LuaJIT 2.1.0-beta3 and better have exception support locked in for all platforms (mostly)
|
|
||||||
#define SOL_PROPAGATE_EXCEPTIONS_I_ SOL_DEFAULT_ON
|
|
||||||
#elif SOL_LUAJIT_VERSION_I_ >= 20000
|
|
||||||
// LuaJIT 2.0.x have exception support only on x64 builds
|
|
||||||
#if SOL_IS_ON(SOL_PLATFORM_X64_I_)
|
|
||||||
#define SOL_PROPAGATE_EXCEPTIONS_I_ SOL_DEFAULT_ON
|
|
||||||
#else
|
|
||||||
#define SOL_PROPAGATE_EXCEPTIONS_I_ SOL_OFF
|
|
||||||
#endif
|
|
||||||
#else
|
#else
|
||||||
// otherwise, there is no exception safety for
|
#if SOL_IS_ON(SOL_USE_LUAJIT)
|
||||||
// shoving exceptions through Lua and errors should
|
#if SOL_USE(SOL_LUAJIT_VERSION) >= 20100
|
||||||
// always be serialized
|
// LuaJIT 2.1.0-beta3 and better have exception support locked in for all platforms (mostly)
|
||||||
#define SOL_PROPAGATE_EXCEPTIONS_I_ SOL_DEFAULT_OFF
|
#define SOL_PROPAGATE_EXCEPTIONS_I_ SOL_DEFAULT_ON
|
||||||
|
#elif SOL_USE(SOL_LUAJIT_VERSION) >= 20000
|
||||||
|
// LuaJIT 2.0.x have exception support only on x64 builds
|
||||||
|
#if SOL_IS_ON(SOL_PLATFORM_X64)
|
||||||
|
#define SOL_PROPAGATE_EXCEPTIONS_I_ SOL_DEFAULT_ON
|
||||||
|
#else
|
||||||
|
#define SOL_PROPAGATE_EXCEPTIONS_I_ SOL_DEFAULT_OFF
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
// otherwise, there is no exception safety for
|
||||||
|
// shoving exceptions through Lua and errors should
|
||||||
|
// always be serialized
|
||||||
|
#define SOL_PROPAGATE_EXCEPTIONS_I_ SOL_DEFAULT_OFF
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Some configurations work with exceptions,
|
// Some configurations work with exceptions,
|
||||||
|
|
@ -144,13 +166,14 @@
|
||||||
#define SOL_EXCEPTIONS_CATCH_ALL_I_ SOL_OFF
|
#define SOL_EXCEPTIONS_CATCH_ALL_I_ SOL_OFF
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
#if SOL_IS_ON(SOL_USE_LUAJIT_I_)
|
#if SOL_IS_ON(SOL_USE_LUAJIT) || SOL_IS_ON(SOL_USING_CXX_LUAJIT)
|
||||||
#define SOL_EXCEPTIONS_CATCH_ALL_I_ SOL_DEFAULT_OFF
|
#define SOL_EXCEPTIONS_CATCH_ALL_I_ SOL_DEFAULT_OFF
|
||||||
#elif SOL_IS_ON(SOL_USE_CXX_LUAJIT_I_)
|
#elif SOL_IS_ON(SOL_USING_CXX_LUA)
|
||||||
#define SOL_EXCEPTIONS_CATCH_ALL_I_ SOL_DEFAULT_OFF
|
// C++ builds of Lua will throw an exception to implement its `yield` behavior;
|
||||||
#elif SOL_IS_ON(SOL_USE_CXX_LUA_I_)
|
// it is irresponsible to "catch all" on this setting.
|
||||||
#define SOL_EXCEPTIONS_CATCH_ALL_I_ SOL_DEFAULT_OFF
|
#define SOL_EXCEPTIONS_CATCH_ALL_I_ SOL_DEFAULT_OFF
|
||||||
#else
|
#else
|
||||||
|
// Otherwise, by default, everyhting should be caught.
|
||||||
#define SOL_EXCEPTIONS_CATCH_ALL_I_ SOL_DEFAULT_ON
|
#define SOL_EXCEPTIONS_CATCH_ALL_I_ SOL_DEFAULT_ON
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -162,7 +185,7 @@
|
||||||
#define SOL_USE_LUAJIT_EXCEPTION_TRAMPOLINE_I_ SOL_OFF
|
#define SOL_USE_LUAJIT_EXCEPTION_TRAMPOLINE_I_ SOL_OFF
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
#if SOL_IS_OFF(SOL_PROPAGATE_EXCEPTIONS_I_) && SOL_IS_ON(SOL_USE_LUAJIT_I_)
|
#if SOL_IS_OFF(SOL_PROPAGATE_EXCEPTIONS) && SOL_IS_ON(SOL_USE_LUAJIT)
|
||||||
#define SOL_USE_LUAJIT_EXCEPTION_TRAMPOLINE_I_ SOL_ON
|
#define SOL_USE_LUAJIT_EXCEPTION_TRAMPOLINE_I_ SOL_ON
|
||||||
#else
|
#else
|
||||||
#define SOL_USE_LUAJIT_EXCEPTION_TRAMPOLINE_I_ SOL_DEFAULT_OFF
|
#define SOL_USE_LUAJIT_EXCEPTION_TRAMPOLINE_I_ SOL_DEFAULT_OFF
|
||||||
|
|
@ -176,7 +199,7 @@
|
||||||
#define SOL_LUAL_STREAM_USE_CLOSE_FUNCTION_I_ SOL_OFF
|
#define SOL_LUAL_STREAM_USE_CLOSE_FUNCTION_I_ SOL_OFF
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
#if SOL_IS_OFF(SOL_USE_LUAJIT_I_) && (SOL_LUA_VERSION > 501)
|
#if SOL_IS_OFF(SOL_USE_LUAJIT) && (SOL_LUA_VERSION > 501)
|
||||||
#define SOL_LUAL_STREAM_USE_CLOSE_FUNCTION_I_ SOL_ON
|
#define SOL_LUAL_STREAM_USE_CLOSE_FUNCTION_I_ SOL_ON
|
||||||
#else
|
#else
|
||||||
#define SOL_LUAL_STREAM_USE_CLOSE_FUNCTION_I_ SOL_DEFAULT_OFF
|
#define SOL_LUAL_STREAM_USE_CLOSE_FUNCTION_I_ SOL_DEFAULT_OFF
|
||||||
|
|
@ -192,7 +215,11 @@
|
||||||
#else
|
#else
|
||||||
// Lua 5.2 only (deprecated in 5.3 (503)) (Can be turned on with Compat flags)
|
// Lua 5.2 only (deprecated in 5.3 (503)) (Can be turned on with Compat flags)
|
||||||
// Lua 5.2, or other versions of Lua with the compat flag, or Lua that is not 5.2 with the specific define (5.4.1 either removed it entirely or broke it)
|
// Lua 5.2, or other versions of Lua with the compat flag, or Lua that is not 5.2 with the specific define (5.4.1 either removed it entirely or broke it)
|
||||||
#if (SOL_LUA_VERSION_I_ == 502) || (defined(LUA_COMPAT_BITLIB) && (LUA_COMPAT_BITLIB != 0)) || (SOL_LUA_VERSION_I_ < 504 && (defined(LUA_COMPAT_5_2) && (LUA_COMPAT_5_2 != 0)))
|
#if (SOL_LUA_VERSION_I_ == 502)
|
||||||
|
#define SOL_LUA_BIT32_LIB_I_ SOL_ON
|
||||||
|
#elif defined(LUA_COMPAT_BITLIB)
|
||||||
|
#define SOL_LUA_BIT32_LIB_I_ SOL_ON
|
||||||
|
#elif (SOL_LUA_VERSION_I_ < 504 && defined(LUA_COMPAT_5_2))
|
||||||
#define SOL_LUA_BIT32_LIB_I_ SOL_ON
|
#define SOL_LUA_BIT32_LIB_I_ SOL_ON
|
||||||
#else
|
#else
|
||||||
#define SOL_LUA_BIT32_LIB_I_ SOL_DEFAULT_OFF
|
#define SOL_LUA_BIT32_LIB_I_ SOL_DEFAULT_OFF
|
||||||
|
|
@ -215,4 +242,4 @@
|
||||||
|
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
#endif // SOL_COMPATIBILITY_VERSION_HPP
|
#endif // SOL_COMPATIBILITY_LUA_VERSION_HPP
|
||||||
|
|
|
||||||
50
extern/sol3/sol/config.hpp
vendored
Normal file
50
extern/sol3/sol/config.hpp
vendored
Normal file
|
|
@ -0,0 +1,50 @@
|
||||||
|
// sol2
|
||||||
|
|
||||||
|
// The MIT License (MIT)
|
||||||
|
|
||||||
|
// Copyright (c) 2013-2022 Rapptz, ThePhD and contributors
|
||||||
|
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
|
// this software and associated documentation files (the "Software"), to deal in
|
||||||
|
// the Software without restriction, including without limitation the rights to
|
||||||
|
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||||
|
// the Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
|
// subject to the following conditions:
|
||||||
|
|
||||||
|
// The above copyright notice and this permission notice shall be included in all
|
||||||
|
// copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
#ifndef SOL_CONFIG_HPP
|
||||||
|
#define SOL_CONFIG_HPP
|
||||||
|
|
||||||
|
/* Base, empty configuration file!
|
||||||
|
|
||||||
|
To override, place a file in your include paths of the form:
|
||||||
|
|
||||||
|
|
||||||
|
. (your include path here)
|
||||||
|
| sol (directory, or equivalent)
|
||||||
|
| config.hpp (your config.hpp file)
|
||||||
|
|
||||||
|
|
||||||
|
So that when sol2 includes the file
|
||||||
|
|
||||||
|
|
||||||
|
#include <sol/config.hpp>
|
||||||
|
|
||||||
|
|
||||||
|
it gives you the configuration values you desire. Configuration values can be
|
||||||
|
seen in the safety.rst of the doc/src, or at
|
||||||
|
https://sol2.readthedocs.io/en/latest/safety.html ! You can also pass them through
|
||||||
|
the build system, or the command line options of your compiler.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
#endif // SOL_CONFIG_HPP
|
||||||
12
extern/sol3/sol/coroutine.hpp
vendored
12
extern/sol3/sol/coroutine.hpp
vendored
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
// The MIT License (MIT)
|
// The MIT License (MIT)
|
||||||
|
|
||||||
// Copyright (c) 2013-2021 Rapptz, ThePhD and contributors
|
// Copyright (c) 2013-2022 Rapptz, ThePhD and contributors
|
||||||
|
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
// this software and associated documentation files (the "Software"), to deal in
|
// this software and associated documentation files (the "Software"), to deal in
|
||||||
|
|
@ -94,7 +94,7 @@ namespace sol {
|
||||||
meta::neg<std::is_same<lua_nil_t, meta::unqualified_t<T>>>, is_lua_reference<meta::unqualified_t<T>>> = meta::enabler>
|
meta::neg<std::is_same<lua_nil_t, meta::unqualified_t<T>>>, is_lua_reference<meta::unqualified_t<T>>> = meta::enabler>
|
||||||
basic_coroutine(T&& r) noexcept
|
basic_coroutine(T&& r) noexcept
|
||||||
: base_t(std::forward<T>(r)), m_error_handler(detail::get_default_handler<reference, is_main_threaded<base_t>::value>(r.lua_state())) {
|
: base_t(std::forward<T>(r)), m_error_handler(detail::get_default_handler<reference, is_main_threaded<base_t>::value>(r.lua_state())) {
|
||||||
#if SOL_IS_ON(SOL_SAFE_REFERENCES_I_)
|
#if SOL_IS_ON(SOL_SAFE_REFERENCES)
|
||||||
if (!is_function<meta::unqualified_t<T>>::value) {
|
if (!is_function<meta::unqualified_t<T>>::value) {
|
||||||
auto pp = stack::push_pop(*this);
|
auto pp = stack::push_pop(*this);
|
||||||
constructor_handler handler {};
|
constructor_handler handler {};
|
||||||
|
|
@ -157,7 +157,7 @@ namespace sol {
|
||||||
}
|
}
|
||||||
template <typename T, meta::enable<is_lua_reference<meta::unqualified_t<T>>> = meta::enabler>
|
template <typename T, meta::enable<is_lua_reference<meta::unqualified_t<T>>> = meta::enabler>
|
||||||
basic_coroutine(lua_State* L, T&& r, handler_t eh) : base_t(L, std::forward<T>(r)), m_error_handler(std::move(eh)) {
|
basic_coroutine(lua_State* L, T&& r, handler_t eh) : base_t(L, std::forward<T>(r)), m_error_handler(std::move(eh)) {
|
||||||
#if SOL_IS_ON(SOL_SAFE_REFERENCES_I_)
|
#if SOL_IS_ON(SOL_SAFE_REFERENCES)
|
||||||
auto pp = stack::push_pop(*this);
|
auto pp = stack::push_pop(*this);
|
||||||
constructor_handler handler {};
|
constructor_handler handler {};
|
||||||
stack::check<basic_coroutine>(lua_state(), -1, handler);
|
stack::check<basic_coroutine>(lua_state(), -1, handler);
|
||||||
|
|
@ -180,7 +180,7 @@ namespace sol {
|
||||||
: basic_coroutine(L, index, detail::get_default_handler<reference, is_main_threaded<base_t>::value>(L)) {
|
: basic_coroutine(L, index, detail::get_default_handler<reference, is_main_threaded<base_t>::value>(L)) {
|
||||||
}
|
}
|
||||||
basic_coroutine(lua_State* L, absolute_index index, handler_t eh) : base_t(L, index), m_error_handler(std::move(eh)) {
|
basic_coroutine(lua_State* L, absolute_index index, handler_t eh) : base_t(L, index), m_error_handler(std::move(eh)) {
|
||||||
#if SOL_IS_ON(SOL_SAFE_REFERENCES_I_)
|
#if SOL_IS_ON(SOL_SAFE_REFERENCES)
|
||||||
constructor_handler handler {};
|
constructor_handler handler {};
|
||||||
stack::check<basic_coroutine>(L, index, handler);
|
stack::check<basic_coroutine>(L, index, handler);
|
||||||
#endif // Safety
|
#endif // Safety
|
||||||
|
|
@ -189,7 +189,7 @@ namespace sol {
|
||||||
: basic_coroutine(L, index, detail::get_default_handler<reference, is_main_threaded<base_t>::value>(L)) {
|
: basic_coroutine(L, index, detail::get_default_handler<reference, is_main_threaded<base_t>::value>(L)) {
|
||||||
}
|
}
|
||||||
basic_coroutine(lua_State* L, raw_index index, handler_t eh) : base_t(L, index), m_error_handler(std::move(eh)) {
|
basic_coroutine(lua_State* L, raw_index index, handler_t eh) : base_t(L, index), m_error_handler(std::move(eh)) {
|
||||||
#if SOL_IS_ON(SOL_SAFE_REFERENCES_I_)
|
#if SOL_IS_ON(SOL_SAFE_REFERENCES)
|
||||||
constructor_handler handler {};
|
constructor_handler handler {};
|
||||||
stack::check<basic_coroutine>(L, index, handler);
|
stack::check<basic_coroutine>(L, index, handler);
|
||||||
#endif // Safety
|
#endif // Safety
|
||||||
|
|
@ -198,7 +198,7 @@ namespace sol {
|
||||||
: basic_coroutine(L, index, detail::get_default_handler<reference, is_main_threaded<base_t>::value>(L)) {
|
: basic_coroutine(L, index, detail::get_default_handler<reference, is_main_threaded<base_t>::value>(L)) {
|
||||||
}
|
}
|
||||||
basic_coroutine(lua_State* L, ref_index index, handler_t eh) : base_t(L, index), m_error_handler(std::move(eh)) {
|
basic_coroutine(lua_State* L, ref_index index, handler_t eh) : base_t(L, index), m_error_handler(std::move(eh)) {
|
||||||
#if SOL_IS_ON(SOL_SAFE_REFERENCES_I_)
|
#if SOL_IS_ON(SOL_SAFE_REFERENCES)
|
||||||
auto pp = stack::push_pop(*this);
|
auto pp = stack::push_pop(*this);
|
||||||
constructor_handler handler {};
|
constructor_handler handler {};
|
||||||
stack::check<basic_coroutine>(lua_state(), -1, handler);
|
stack::check<basic_coroutine>(lua_state(), -1, handler);
|
||||||
|
|
|
||||||
115
extern/sol3/sol/debug.hpp
vendored
115
extern/sol3/sol/debug.hpp
vendored
|
|
@ -1,52 +1,63 @@
|
||||||
// sol2
|
// sol2
|
||||||
|
|
||||||
// The MIT License (MIT)
|
// The MIT License (MIT)
|
||||||
|
|
||||||
// Copyright (c) 2013-2021 Rapptz, ThePhD and contributors
|
// Copyright (c) 2013-2022 Rapptz, ThePhD and contributors
|
||||||
|
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
// this software and associated documentation files (the "Software"), to deal in
|
// this software and associated documentation files (the "Software"), to deal in
|
||||||
// the Software without restriction, including without limitation the rights to
|
// the Software without restriction, including without limitation the rights to
|
||||||
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||||
// the Software, and to permit persons to whom the Software is furnished to do so,
|
// the Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
// subject to the following conditions:
|
// subject to the following conditions:
|
||||||
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
// The above copyright notice and this permission notice shall be included in all
|
||||||
// copies or substantial portions of the Software.
|
// copies or substantial portions of the Software.
|
||||||
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
#ifndef SOL_DEBUG_HPP
|
#ifndef SOL_DEBUG_HPP
|
||||||
#define SOL_DEBUG_HPP
|
#define SOL_DEBUG_HPP
|
||||||
|
|
||||||
#include <sol/stack.hpp>
|
#include <sol/stack.hpp>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
namespace sol { namespace detail { namespace debug {
|
namespace sol { namespace detail { namespace debug {
|
||||||
inline std::string dump_types(lua_State* L) {
|
inline std::string dump_types(lua_State* L) {
|
||||||
std::string visual;
|
std::string visual;
|
||||||
std::size_t size = lua_gettop(L) + 1;
|
std::size_t size = lua_gettop(L) + 1;
|
||||||
for (std::size_t i = 1; i < size; ++i) {
|
for (std::size_t i = 1; i < size; ++i) {
|
||||||
if (i != 1) {
|
if (i != 1) {
|
||||||
visual += " | ";
|
visual += " | ";
|
||||||
}
|
}
|
||||||
visual += type_name(L, stack::get<type>(L, static_cast<int>(i)));
|
visual += type_name(L, stack::get<type>(L, static_cast<int>(i)));
|
||||||
}
|
}
|
||||||
return visual;
|
return visual;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void print_stack(lua_State* L) {
|
inline void print_stack(lua_State* L) {
|
||||||
std::cout << dump_types(L) << std::endl;
|
std::cout << dump_types(L) << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void print_section(const std::string& message, lua_State* L) {
|
inline void print_section(const std::string& message, lua_State* L) {
|
||||||
std::cout << "-- " << message << " -- [ " << dump_types(L) << " ]" << std::endl;
|
std::cout << "-- " << message << " -- [ " << dump_types(L) << " ]" << std::endl;
|
||||||
}
|
}
|
||||||
}}} // namespace sol::detail::debug
|
|
||||||
|
inline void print_lua_information(lua_State* L) {
|
||||||
#endif // SOL_DEBUG_HPP
|
std::cout << "Lua Version: " << SOL_USE(SOL_LUA_VERSION) << std::endl;
|
||||||
|
std::cout << "Lua (C++): " << SOL_IS_ON(SOL_USING_CXX_LUA) << std::endl;
|
||||||
|
std::cout << "Trampoline Propagate Exceptions?: " << SOL_IS_ON(SOL_PROPAGATE_EXCEPTIONS) << std::endl;
|
||||||
|
std::cout << "Catch-all Exceptions?: " << SOL_IS_ON(SOL_EXCEPTIONS_CATCH_ALL) << std::endl;
|
||||||
|
std::cout << "LuaJIT: " << SOL_IS_ON(SOL_USE_LUAJIT) << std::endl;
|
||||||
|
std::cout << "LuaJIT Version: " << SOL_USE(SOL_LUAJIT_VERSION) << std::endl;
|
||||||
|
std::cout << "LuaJIT (C++): " << SOL_IS_ON(SOL_USING_CXX_LUAJIT) << std::endl;
|
||||||
|
std::cout << "LuaJIT Exception Trampoline: " << SOL_IS_ON(SOL_USE_LUAJIT_EXCEPTION_TRAMPOLINE) << std::endl;
|
||||||
|
}
|
||||||
|
}}} // namespace sol::detail::debug
|
||||||
|
|
||||||
|
#endif // SOL_DEBUG_HPP
|
||||||
|
|
|
||||||
8
extern/sol3/sol/demangle.hpp
vendored
8
extern/sol3/sol/demangle.hpp
vendored
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
// The MIT License (MIT)
|
// The MIT License (MIT)
|
||||||
|
|
||||||
// Copyright (c) 2013-2021 Rapptz, ThePhD and contributors
|
// Copyright (c) 2013-2022 Rapptz, ThePhD and contributors
|
||||||
|
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
// this software and associated documentation files (the "Software"), to deal in
|
// this software and associated documentation files (the "Software"), to deal in
|
||||||
|
|
@ -28,7 +28,7 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <cctype>
|
#include <cctype>
|
||||||
#if SOL_IS_ON(SOL_MINGW_CCTYPE_IS_POISONED_I_)
|
#if SOL_IS_ON(SOL_MINGW_CCTYPE_IS_POISONED)
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
}
|
}
|
||||||
|
|
@ -47,7 +47,7 @@ namespace sol { namespace detail {
|
||||||
"`anonymous namespace'" } };
|
"`anonymous namespace'" } };
|
||||||
|
|
||||||
|
|
||||||
#if SOL_IS_ON(SOL_COMPILER_GCC_I_) || SOL_IS_ON(SOL_COMPILER_CLANG_I_)
|
#if SOL_IS_ON(SOL_COMPILER_GCC) || SOL_IS_ON(SOL_COMPILER_CLANG)
|
||||||
inline std::string ctti_get_type_name_from_sig(std::string name) {
|
inline std::string ctti_get_type_name_from_sig(std::string name) {
|
||||||
// cardinal sins from MINGW
|
// cardinal sins from MINGW
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
@ -85,7 +85,7 @@ namespace sol { namespace detail {
|
||||||
inline std::string ctti_get_type_name() {
|
inline std::string ctti_get_type_name() {
|
||||||
return ctti_get_type_name_from_sig(__PRETTY_FUNCTION__);
|
return ctti_get_type_name_from_sig(__PRETTY_FUNCTION__);
|
||||||
}
|
}
|
||||||
#elif SOL_IS_ON(SOL_COMPILER_VCXX_I_)
|
#elif SOL_IS_ON(SOL_COMPILER_VCXX)
|
||||||
inline std::string ctti_get_type_name_from_sig(std::string name) {
|
inline std::string ctti_get_type_name_from_sig(std::string name) {
|
||||||
std::size_t start = name.find("get_type_name");
|
std::size_t start = name.find("get_type_name");
|
||||||
if (start == std::string::npos)
|
if (start == std::string::npos)
|
||||||
|
|
|
||||||
88
extern/sol3/sol/deprecate.hpp
vendored
88
extern/sol3/sol/deprecate.hpp
vendored
|
|
@ -1,44 +1,44 @@
|
||||||
// sol2
|
// sol2
|
||||||
|
|
||||||
// The MIT License (MIT)
|
// The MIT License (MIT)
|
||||||
|
|
||||||
// Copyright (c) 2013-2021 Rapptz, ThePhD and contributors
|
// Copyright (c) 2013-2022 Rapptz, ThePhD and contributors
|
||||||
|
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
// this software and associated documentation files (the "Software"), to deal in
|
// this software and associated documentation files (the "Software"), to deal in
|
||||||
// the Software without restriction, including without limitation the rights to
|
// the Software without restriction, including without limitation the rights to
|
||||||
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||||
// the Software, and to permit persons to whom the Software is furnished to do so,
|
// the Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
// subject to the following conditions:
|
// subject to the following conditions:
|
||||||
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
// The above copyright notice and this permission notice shall be included in all
|
||||||
// copies or substantial portions of the Software.
|
// copies or substantial portions of the Software.
|
||||||
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
#ifndef SOL_DEPRECATE_HPP
|
#ifndef SOL_DEPRECATE_HPP
|
||||||
#define SOL_DEPRECATE_HPP
|
#define SOL_DEPRECATE_HPP
|
||||||
|
|
||||||
#ifndef SOL_DEPRECATED
|
#ifndef SOL_DEPRECATED
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#define SOL_DEPRECATED __declspec(deprecated)
|
#define SOL_DEPRECATED __declspec(deprecated)
|
||||||
#elif __GNUC__
|
#elif __GNUC__
|
||||||
#define SOL_DEPRECATED __attribute__((deprecated))
|
#define SOL_DEPRECATED __attribute__((deprecated))
|
||||||
#else
|
#else
|
||||||
#define SOL_DEPRECATED [[deprecated]]
|
#define SOL_DEPRECATED [[deprecated]]
|
||||||
#endif // compilers
|
#endif // compilers
|
||||||
#endif // SOL_DEPRECATED
|
#endif // SOL_DEPRECATED
|
||||||
|
|
||||||
namespace sol { namespace detail {
|
namespace sol { namespace detail {
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct SOL_DEPRECATED deprecate_type {
|
struct SOL_DEPRECATED deprecate_type {
|
||||||
using type = T;
|
using type = T;
|
||||||
};
|
};
|
||||||
}} // namespace sol::detail
|
}} // namespace sol::detail
|
||||||
|
|
||||||
#endif // SOL_DEPRECATE_HPP
|
#endif // SOL_DEPRECATE_HPP
|
||||||
|
|
|
||||||
464
extern/sol3/sol/detail/build_version.hpp
vendored
464
extern/sol3/sol/detail/build_version.hpp
vendored
|
|
@ -1,232 +1,232 @@
|
||||||
// sol2
|
// sol2
|
||||||
|
|
||||||
// The MIT License (MIT)
|
// The MIT License (MIT)
|
||||||
|
|
||||||
// Copyright (c) 2013-2021 Rapptz, ThePhD and contributors
|
// Copyright (c) 2013-2022 Rapptz, ThePhD and contributors
|
||||||
|
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
// this software and associated documentation files (the "Software"), to deal in
|
// this software and associated documentation files (the "Software"), to deal in
|
||||||
// the Software without restriction, including without limitation the rights to
|
// the Software without restriction, including without limitation the rights to
|
||||||
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||||
// the Software, and to permit persons to whom the Software is furnished to do so,
|
// the Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
// subject to the following conditions:
|
// subject to the following conditions:
|
||||||
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
// The above copyright notice and this permission notice shall be included in all
|
||||||
// copies or substantial portions of the Software.
|
// copies or substantial portions of the Software.
|
||||||
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#ifndef SOL_DETAIL_BUILD_VERSION_HPP
|
#ifndef SOL_DETAIL_BUILD_VERSION_HPP
|
||||||
#define SOL_DETAIL_BUILD_VERSION_HPP
|
#define SOL_DETAIL_BUILD_VERSION_HPP
|
||||||
|
|
||||||
#include <sol/version.hpp>
|
#include <sol/version.hpp>
|
||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
|
|
||||||
#if defined(SOL_DLL)
|
#if defined(SOL_DLL)
|
||||||
#if (SOL_DLL != 0)
|
#if (SOL_DLL != 0)
|
||||||
#define SOL_DLL_I_ SOL_ON
|
#define SOL_DLL_I_ SOL_ON
|
||||||
#else
|
#else
|
||||||
#define SOL_DLL_I_ SOL_OFF
|
#define SOL_DLL_I_ SOL_OFF
|
||||||
#endif
|
#endif
|
||||||
#elif SOL_IS_ON(SOL_COMPILER_VCXX_I_) && (defined(DLL_) || defined(_DLL))
|
#elif SOL_IS_ON(SOL_COMPILER_VCXX) && (defined(DLL_) || defined(_DLL))
|
||||||
#define SOL_DLL_I_ SOL_DEFAULT_ON
|
#define SOL_DLL_I_ SOL_DEFAULT_ON
|
||||||
#else
|
#else
|
||||||
#define SOL_DLL_I_ SOL_DEFAULT_OFF
|
#define SOL_DLL_I_ SOL_DEFAULT_OFF
|
||||||
#endif // DLL definition
|
#endif // DLL definition
|
||||||
|
|
||||||
#if defined(SOL_HEADER_ONLY)
|
#if defined(SOL_HEADER_ONLY)
|
||||||
#if (SOL_HEADER_ONLY != 0)
|
#if (SOL_HEADER_ONLY != 0)
|
||||||
#define SOL_HEADER_ONLY_I_ SOL_ON
|
#define SOL_HEADER_ONLY_I_ SOL_ON
|
||||||
#else
|
#else
|
||||||
#define SOL_HEADER_ONLY_I_ SOL_OFF
|
#define SOL_HEADER_ONLY_I_ SOL_OFF
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
#define SOL_HEADER_ONLY_I_ SOL_DEFAULT_OFF
|
#define SOL_HEADER_ONLY_I_ SOL_DEFAULT_OFF
|
||||||
#endif // Header only library
|
#endif // Header only library
|
||||||
|
|
||||||
#if defined(SOL_BUILD)
|
#if defined(SOL_BUILD)
|
||||||
#if (SOL_BUILD != 0)
|
#if (SOL_BUILD != 0)
|
||||||
#define SOL_BUILD_I_ SOL_ON
|
#define SOL_BUILD_I_ SOL_ON
|
||||||
#else
|
#else
|
||||||
#define SOL_BUILD_I_ SOL_OFF
|
#define SOL_BUILD_I_ SOL_OFF
|
||||||
#endif
|
#endif
|
||||||
#elif SOL_IS_ON(SOL_HEADER_ONLY_I_)
|
#elif SOL_IS_ON(SOL_HEADER_ONLY)
|
||||||
#define SOL_BUILD_I_ SOL_DEFAULT_OFF
|
#define SOL_BUILD_I_ SOL_DEFAULT_OFF
|
||||||
#else
|
#else
|
||||||
#define SOL_BUILD_I_ SOL_DEFAULT_ON
|
#define SOL_BUILD_I_ SOL_DEFAULT_ON
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(SOL_UNITY_BUILD)
|
#if defined(SOL_UNITY_BUILD)
|
||||||
#if (SOL_UNITY_BUILD != 0)
|
#if (SOL_UNITY_BUILD != 0)
|
||||||
#define SOL_UNITY_BUILD_I_ SOL_ON
|
#define SOL_UNITY_BUILD_I_ SOL_ON
|
||||||
#else
|
#else
|
||||||
#define SOL_UNITY_BUILD_I_ SOL_OFF
|
#define SOL_UNITY_BUILD_I_ SOL_OFF
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
#define SOL_UNITY_BUILD_I_ SOL_DEFAULT_OFF
|
#define SOL_UNITY_BUILD_I_ SOL_DEFAULT_OFF
|
||||||
#endif // Header only library
|
#endif // Header only library
|
||||||
|
|
||||||
#if defined(SOL_C_FUNCTION_LINKAGE)
|
#if defined(SOL_C_FUNCTION_LINKAGE)
|
||||||
#define SOL_C_FUNCTION_LINKAGE_I_ SOL_C_FUNCTION_LINKAGE
|
#define SOL_C_FUNCTION_LINKAGE_I_ SOL_C_FUNCTION_LINKAGE
|
||||||
#else
|
#else
|
||||||
#if SOL_IS_ON(SOL_BUILD_CXX_MODE_I_)
|
#if SOL_IS_ON(SOL_BUILD_CXX_MODE)
|
||||||
// C++
|
// C++
|
||||||
#define SOL_C_FUNCTION_LINKAGE_I_ extern "C"
|
#define SOL_C_FUNCTION_LINKAGE_I_ extern "C"
|
||||||
#else
|
#else
|
||||||
// normal
|
// normal
|
||||||
#define SOL_C_FUNCTION_LINKAGE_I_
|
#define SOL_C_FUNCTION_LINKAGE_I_
|
||||||
#endif // C++ or not
|
#endif // C++ or not
|
||||||
#endif // Linkage specification for C functions
|
#endif // Linkage specification for C functions
|
||||||
|
|
||||||
#if defined(SOL_API_LINKAGE)
|
#if defined(SOL_API_LINKAGE)
|
||||||
#define SOL_API_LINKAGE_I_ SOL_API_LINKAGE
|
#define SOL_API_LINKAGE_I_ SOL_API_LINKAGE
|
||||||
#else
|
#else
|
||||||
#if SOL_IS_ON(SOL_DLL_I_)
|
#if SOL_IS_ON(SOL_DLL)
|
||||||
#if SOL_IS_ON(SOL_COMPILER_VCXX_I_) || SOL_IS_ON(SOL_PLATFORM_WINDOWS_I_) || SOL_IS_ON(SOL_PLATFORM_CYGWIN_I_)
|
#if SOL_IS_ON(SOL_COMPILER_VCXX) || SOL_IS_ON(SOL_PLATFORM_WINDOWS) || SOL_IS_ON(SOL_PLATFORM_CYGWIN)
|
||||||
// MSVC Compiler; or, Windows, or Cygwin platforms
|
// MSVC Compiler; or, Windows, or Cygwin platforms
|
||||||
#if SOL_IS_ON(SOL_BUILD_I_)
|
#if SOL_IS_ON(SOL_BUILD)
|
||||||
// Building the library
|
// Building the library
|
||||||
#if SOL_IS_ON(SOL_COMPILER_GCC_I_)
|
#if SOL_IS_ON(SOL_COMPILER_GCC)
|
||||||
// Using GCC
|
// Using GCC
|
||||||
#define SOL_API_LINKAGE_I_ __attribute__((dllexport))
|
#define SOL_API_LINKAGE_I_ __attribute__((dllexport))
|
||||||
#else
|
#else
|
||||||
// Using Clang, MSVC, etc...
|
// Using Clang, MSVC, etc...
|
||||||
#define SOL_API_LINKAGE_I_ __declspec(dllexport)
|
#define SOL_API_LINKAGE_I_ __declspec(dllexport)
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
#if SOL_IS_ON(SOL_COMPILER_GCC_I_)
|
#if SOL_IS_ON(SOL_COMPILER_GCC)
|
||||||
#define SOL_API_LINKAGE_I_ __attribute__((dllimport))
|
#define SOL_API_LINKAGE_I_ __attribute__((dllimport))
|
||||||
#else
|
#else
|
||||||
#define SOL_API_LINKAGE_I_ __declspec(dllimport)
|
#define SOL_API_LINKAGE_I_ __declspec(dllimport)
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
// extern if building normally on non-MSVC
|
// extern if building normally on non-MSVC
|
||||||
#define SOL_API_LINKAGE_I_ extern
|
#define SOL_API_LINKAGE_I_ extern
|
||||||
#endif
|
#endif
|
||||||
#elif SOL_IS_ON(SOL_UNITY_BUILD_I_)
|
#elif SOL_IS_ON(SOL_UNITY_BUILD)
|
||||||
// Built-in library, like how stb typical works
|
// Built-in library, like how stb typical works
|
||||||
#if SOL_IS_ON(SOL_HEADER_ONLY_I_)
|
#if SOL_IS_ON(SOL_HEADER_ONLY)
|
||||||
// Header only, so functions are defined "inline"
|
// Header only, so functions are defined "inline"
|
||||||
#define SOL_API_LINKAGE_I_ inline
|
#define SOL_API_LINKAGE_I_ inline
|
||||||
#else
|
#else
|
||||||
// Not header only, so seperately compiled files
|
// Not header only, so seperately compiled files
|
||||||
#define SOL_API_LINKAGE_I_ extern
|
#define SOL_API_LINKAGE_I_ extern
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
// Normal static library
|
// Normal static library
|
||||||
#if SOL_IS_ON(SOL_BUILD_CXX_MODE_I_)
|
#if SOL_IS_ON(SOL_BUILD_CXX_MODE)
|
||||||
#define SOL_API_LINKAGE_I_
|
#define SOL_API_LINKAGE_I_
|
||||||
#else
|
#else
|
||||||
#define SOL_API_LINKAGE_I_ extern
|
#define SOL_API_LINKAGE_I_ extern
|
||||||
#endif
|
#endif
|
||||||
#endif // DLL or not
|
#endif // DLL or not
|
||||||
#endif // Build definitions
|
#endif // Build definitions
|
||||||
|
|
||||||
#if defined(SOL_PUBLIC_FUNC_DECL)
|
#if defined(SOL_PUBLIC_FUNC_DECL)
|
||||||
#define SOL_PUBLIC_FUNC_DECL_I_ SOL_PUBLIC_FUNC_DECL
|
#define SOL_PUBLIC_FUNC_DECL_I_ SOL_PUBLIC_FUNC_DECL
|
||||||
#else
|
#else
|
||||||
#define SOL_PUBLIC_FUNC_DECL_I_ SOL_API_LINKAGE_I_
|
#define SOL_PUBLIC_FUNC_DECL_I_ SOL_API_LINKAGE_I_
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(SOL_INTERNAL_FUNC_DECL_)
|
#if defined(SOL_INTERNAL_FUNC_DECL_)
|
||||||
#define SOL_INTERNAL_FUNC_DECL_I_ SOL_INTERNAL_FUNC_DECL_
|
#define SOL_INTERNAL_FUNC_DECL_I_ SOL_INTERNAL_FUNC_DECL_
|
||||||
#else
|
#else
|
||||||
#define SOL_INTERNAL_FUNC_DECL_I_ SOL_API_LINKAGE_I_
|
#define SOL_INTERNAL_FUNC_DECL_I_ SOL_API_LINKAGE_I_
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(SOL_PUBLIC_FUNC_DEF)
|
#if defined(SOL_PUBLIC_FUNC_DEF)
|
||||||
#define SOL_PUBLIC_FUNC_DEF_I_ SOL_PUBLIC_FUNC_DEF
|
#define SOL_PUBLIC_FUNC_DEF_I_ SOL_PUBLIC_FUNC_DEF
|
||||||
#else
|
#else
|
||||||
#define SOL_PUBLIC_FUNC_DEF_I_ SOL_API_LINKAGE_I_
|
#define SOL_PUBLIC_FUNC_DEF_I_ SOL_API_LINKAGE_I_
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(SOL_INTERNAL_FUNC_DEF)
|
#if defined(SOL_INTERNAL_FUNC_DEF)
|
||||||
#define SOL_INTERNAL_FUNC_DEF_I_ SOL_INTERNAL_FUNC_DEF
|
#define SOL_INTERNAL_FUNC_DEF_I_ SOL_INTERNAL_FUNC_DEF
|
||||||
#else
|
#else
|
||||||
#define SOL_INTERNAL_FUNC_DEF_I_ SOL_API_LINKAGE_I_
|
#define SOL_INTERNAL_FUNC_DEF_I_ SOL_API_LINKAGE_I_
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(SOL_FUNC_DECL)
|
#if defined(SOL_FUNC_DECL)
|
||||||
#define SOL_FUNC_DECL_I_ SOL_FUNC_DECL
|
#define SOL_FUNC_DECL_I_ SOL_FUNC_DECL
|
||||||
#elif SOL_IS_ON(SOL_HEADER_ONLY_I_)
|
#elif SOL_IS_ON(SOL_HEADER_ONLY)
|
||||||
#define SOL_FUNC_DECL_I_
|
#define SOL_FUNC_DECL_I_
|
||||||
#elif SOL_IS_ON(SOL_DLL_I_)
|
#elif SOL_IS_ON(SOL_DLL)
|
||||||
#if SOL_IS_ON(SOL_COMPILER_VCXX_I_)
|
#if SOL_IS_ON(SOL_COMPILER_VCXX)
|
||||||
#if SOL_IS_ON(SOL_BUILD_I_)
|
#if SOL_IS_ON(SOL_BUILD)
|
||||||
#define SOL_FUNC_DECL_I_ extern __declspec(dllexport)
|
#define SOL_FUNC_DECL_I_ extern __declspec(dllexport)
|
||||||
#else
|
#else
|
||||||
#define SOL_FUNC_DECL_I_ extern __declspec(dllimport)
|
#define SOL_FUNC_DECL_I_ extern __declspec(dllimport)
|
||||||
#endif
|
#endif
|
||||||
#elif SOL_IS_ON(SOL_COMPILER_GCC_I_) || SOL_IS_ON(SOL_COMPILER_CLANG_I_)
|
#elif SOL_IS_ON(SOL_COMPILER_GCC) || SOL_IS_ON(SOL_COMPILER_CLANG)
|
||||||
#define SOL_FUNC_DECL_I_ extern __attribute__((visibility("default")))
|
#define SOL_FUNC_DECL_I_ extern __attribute__((visibility("default")))
|
||||||
#else
|
#else
|
||||||
#define SOL_FUNC_DECL_I_ extern
|
#define SOL_FUNC_DECL_I_ extern
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(SOL_FUNC_DEFN)
|
#if defined(SOL_FUNC_DEFN)
|
||||||
#define SOL_FUNC_DEFN_I_ SOL_FUNC_DEFN
|
#define SOL_FUNC_DEFN_I_ SOL_FUNC_DEFN
|
||||||
#elif SOL_IS_ON(SOL_HEADER_ONLY_I_)
|
#elif SOL_IS_ON(SOL_HEADER_ONLY)
|
||||||
#define SOL_FUNC_DEFN_I_ inline
|
#define SOL_FUNC_DEFN_I_ inline
|
||||||
#elif SOL_IS_ON(SOL_DLL_I_)
|
#elif SOL_IS_ON(SOL_DLL)
|
||||||
#if SOL_IS_ON(SOL_COMPILER_VCXX_I_)
|
#if SOL_IS_ON(SOL_COMPILER_VCXX)
|
||||||
#if SOL_IS_ON(SOL_BUILD_I_)
|
#if SOL_IS_ON(SOL_BUILD)
|
||||||
#define SOL_FUNC_DEFN_I_ __declspec(dllexport)
|
#define SOL_FUNC_DEFN_I_ __declspec(dllexport)
|
||||||
#else
|
#else
|
||||||
#define SOL_FUNC_DEFN_I_ __declspec(dllimport)
|
#define SOL_FUNC_DEFN_I_ __declspec(dllimport)
|
||||||
#endif
|
#endif
|
||||||
#elif SOL_IS_ON(SOL_COMPILER_GCC_I_) || SOL_IS_ON(SOL_COMPILER_CLANG_I_)
|
#elif SOL_IS_ON(SOL_COMPILER_GCC) || SOL_IS_ON(SOL_COMPILER_CLANG)
|
||||||
#define SOL_FUNC_DEFN_I_ __attribute__((visibility("default")))
|
#define SOL_FUNC_DEFN_I_ __attribute__((visibility("default")))
|
||||||
#else
|
#else
|
||||||
#define SOL_FUNC_DEFN_I_
|
#define SOL_FUNC_DEFN_I_
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(SOL_HIDDEN_FUNC_DECL)
|
#if defined(SOL_HIDDEN_FUNC_DECL)
|
||||||
#define SOL_HIDDEN_FUNC_DECL_I_ SOL_HIDDEN_FUNC_DECL
|
#define SOL_HIDDEN_FUNC_DECL_I_ SOL_HIDDEN_FUNC_DECL
|
||||||
#elif SOL_IS_ON(SOL_HEADER_ONLY_I_)
|
#elif SOL_IS_ON(SOL_HEADER_ONLY)
|
||||||
#define SOL_HIDDEN_FUNC_DECL_I_
|
#define SOL_HIDDEN_FUNC_DECL_I_
|
||||||
#elif SOL_IS_ON(SOL_DLL_I_)
|
#elif SOL_IS_ON(SOL_DLL)
|
||||||
#if SOL_IS_ON(SOL_COMPILER_VCXX_I_)
|
#if SOL_IS_ON(SOL_COMPILER_VCXX)
|
||||||
#if SOL_IS_ON(SOL_BUILD_I_)
|
#if SOL_IS_ON(SOL_BUILD)
|
||||||
#define SOL_HIDDEN_FUNC_DECL_I_ extern __declspec(dllexport)
|
#define SOL_HIDDEN_FUNC_DECL_I_ extern __declspec(dllexport)
|
||||||
#else
|
#else
|
||||||
#define SOL_HIDDEN_FUNC_DECL_I_ extern __declspec(dllimport)
|
#define SOL_HIDDEN_FUNC_DECL_I_ extern __declspec(dllimport)
|
||||||
#endif
|
#endif
|
||||||
#elif SOL_IS_ON(SOL_COMPILER_GCC_I_) || SOL_IS_ON(SOL_COMPILER_CLANG_I_)
|
#elif SOL_IS_ON(SOL_COMPILER_GCC) || SOL_IS_ON(SOL_COMPILER_CLANG)
|
||||||
#define SOL_HIDDEN_FUNC_DECL_I_ extern __attribute__((visibility("default")))
|
#define SOL_HIDDEN_FUNC_DECL_I_ extern __attribute__((visibility("default")))
|
||||||
#else
|
#else
|
||||||
#define SOL_HIDDEN_FUNC_DECL_I_ extern
|
#define SOL_HIDDEN_FUNC_DECL_I_ extern
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(SOL_HIDDEN_FUNC_DEFN)
|
#if defined(SOL_HIDDEN_FUNC_DEFN)
|
||||||
#define SOL_HIDDEN_FUNC_DEFN_I_ SOL_HIDDEN_FUNC_DEFN
|
#define SOL_HIDDEN_FUNC_DEFN_I_ SOL_HIDDEN_FUNC_DEFN
|
||||||
#elif SOL_IS_ON(SOL_HEADER_ONLY_I_)
|
#elif SOL_IS_ON(SOL_HEADER_ONLY)
|
||||||
#define SOL_HIDDEN_FUNC_DEFN_I_ inline
|
#define SOL_HIDDEN_FUNC_DEFN_I_ inline
|
||||||
#elif SOL_IS_ON(SOL_DLL_I_)
|
#elif SOL_IS_ON(SOL_DLL)
|
||||||
#if SOL_IS_ON(SOL_COMPILER_VCXX_I_)
|
#if SOL_IS_ON(SOL_COMPILER_VCXX)
|
||||||
#if SOL_IS_ON(SOL_BUILD_I_)
|
#if SOL_IS_ON(SOL_BUILD)
|
||||||
#define SOL_HIDDEN_FUNC_DEFN_I_
|
#define SOL_HIDDEN_FUNC_DEFN_I_
|
||||||
#else
|
#else
|
||||||
#define SOL_HIDDEN_FUNC_DEFN_I_
|
#define SOL_HIDDEN_FUNC_DEFN_I_
|
||||||
#endif
|
#endif
|
||||||
#elif SOL_IS_ON(SOL_COMPILER_GCC_I_) || SOL_IS_ON(SOL_COMPILER_CLANG_I_)
|
#elif SOL_IS_ON(SOL_COMPILER_GCC) || SOL_IS_ON(SOL_COMPILER_CLANG)
|
||||||
#define SOL_HIDDEN_FUNC_DEFN_I_ __attribute__((visibility("hidden")))
|
#define SOL_HIDDEN_FUNC_DEFN_I_ __attribute__((visibility("hidden")))
|
||||||
#else
|
#else
|
||||||
#define SOL_HIDDEN_FUNC_DEFN_I_
|
#define SOL_HIDDEN_FUNC_DEFN_I_
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
#endif // SOL_DETAIL_BUILD_VERSION_HPP
|
#endif // SOL_DETAIL_BUILD_VERSION_HPP
|
||||||
|
|
|
||||||
154
extern/sol3/sol/dump_handler.hpp
vendored
154
extern/sol3/sol/dump_handler.hpp
vendored
|
|
@ -1,77 +1,77 @@
|
||||||
// sol2
|
// sol2
|
||||||
|
|
||||||
// The MIT License (MIT)
|
// The MIT License (MIT)
|
||||||
|
|
||||||
// Copyright (c) 2013-2021 Rapptz, ThePhD and contributors
|
// Copyright (c) 2013-2022 Rapptz, ThePhD and contributors
|
||||||
|
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
// this software and associated documentation files (the "Software"), to deal in
|
// this software and associated documentation files (the "Software"), to deal in
|
||||||
// the Software without restriction, including without limitation the rights to
|
// the Software without restriction, including without limitation the rights to
|
||||||
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||||
// the Software, and to permit persons to whom the Software is furnished to do so,
|
// the Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
// subject to the following conditions:
|
// subject to the following conditions:
|
||||||
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
// The above copyright notice and this permission notice shall be included in all
|
||||||
// copies or substantial portions of the Software.
|
// copies or substantial portions of the Software.
|
||||||
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
#ifndef SOL_DUMP_HANDLER_HPP
|
#ifndef SOL_DUMP_HANDLER_HPP
|
||||||
#define SOL_DUMP_HANDLER_HPP
|
#define SOL_DUMP_HANDLER_HPP
|
||||||
|
|
||||||
#include <sol/compatibility.hpp>
|
#include <sol/compatibility.hpp>
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <exception>
|
#include <exception>
|
||||||
|
|
||||||
namespace sol {
|
namespace sol {
|
||||||
|
|
||||||
class dump_error : public error {
|
class dump_error : public error {
|
||||||
private:
|
private:
|
||||||
int m_ec;
|
int m_ec;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
dump_error(int error_code_) : error("dump returned non-zero error of " + std::to_string(error_code_)), m_ec(error_code_) {
|
dump_error(int error_code_) : error("dump returned non-zero error of " + std::to_string(error_code_)), m_ec(error_code_) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int error_code() const {
|
int error_code() const {
|
||||||
return m_ec;
|
return m_ec;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
inline int dump_pass_on_error(lua_State* L_, int result_code, lua_Writer writer_function, void* userdata_pointer_, bool strip) {
|
inline int dump_pass_on_error(lua_State* L_, int result_code, lua_Writer writer_function, void* userdata_pointer_, bool strip) {
|
||||||
(void)L_;
|
(void)L_;
|
||||||
(void)writer_function;
|
(void)writer_function;
|
||||||
(void)userdata_pointer_;
|
(void)userdata_pointer_;
|
||||||
(void)strip;
|
(void)strip;
|
||||||
return result_code;
|
return result_code;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int dump_panic_on_error(lua_State* L_, int result_code, lua_Writer writer_function, void* userdata_pointer_, bool strip) {
|
inline int dump_panic_on_error(lua_State* L_, int result_code, lua_Writer writer_function, void* userdata_pointer_, bool strip) {
|
||||||
(void)L_;
|
(void)L_;
|
||||||
(void)writer_function;
|
(void)writer_function;
|
||||||
(void)userdata_pointer_;
|
(void)userdata_pointer_;
|
||||||
(void)strip;
|
(void)strip;
|
||||||
return luaL_error(L_, "a non-zero error code (%d) was returned by the lua_Writer for the dump function", result_code);
|
return luaL_error(L_, "a non-zero error code (%d) was returned by the lua_Writer for the dump function", result_code);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int dump_throw_on_error(lua_State* L_, int result_code, lua_Writer writer_function, void* userdata_pointer_, bool strip) {
|
inline int dump_throw_on_error(lua_State* L_, int result_code, lua_Writer writer_function, void* userdata_pointer_, bool strip) {
|
||||||
#if SOL_IS_OFF(SOL_EXCEPTIONS_I_)
|
#if SOL_IS_OFF(SOL_EXCEPTIONS)
|
||||||
return dump_panic_on_error(L_, result_code, writer_function, userdata_pointer_, strip);
|
return dump_panic_on_error(L_, result_code, writer_function, userdata_pointer_, strip);
|
||||||
#else
|
#else
|
||||||
(void)L_;
|
(void)L_;
|
||||||
(void)writer_function;
|
(void)writer_function;
|
||||||
(void)userdata_pointer_;
|
(void)userdata_pointer_;
|
||||||
(void)strip;
|
(void)strip;
|
||||||
throw dump_error(result_code);
|
throw dump_error(result_code);
|
||||||
#endif // no exceptions stuff
|
#endif // no exceptions stuff
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace sol
|
} // namespace sol
|
||||||
|
|
||||||
#endif // SOL_DUMP_HANDLER_HPP
|
#endif // SOL_DUMP_HANDLER_HPP
|
||||||
|
|
|
||||||
321
extern/sol3/sol/ebco.hpp
vendored
321
extern/sol3/sol/ebco.hpp
vendored
|
|
@ -1,160 +1,161 @@
|
||||||
// sol2
|
// sol2
|
||||||
|
|
||||||
// The MIT License (MIT)
|
// The MIT License (MIT)
|
||||||
|
|
||||||
// Copyright (c) 2013-2021 Rapptz, ThePhD and contributors
|
// Copyright (c) 2013-2022 Rapptz, ThePhD and contributors
|
||||||
|
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
// this software and associated documentation files (the "Software"), to deal in
|
// this software and associated documentation files (the "Software"), to deal in
|
||||||
// the Software without restriction, including without limitation the rights to
|
// the Software without restriction, including without limitation the rights to
|
||||||
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||||
// the Software, and to permit persons to whom the Software is furnished to do so,
|
// the Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
// subject to the following conditions:
|
// subject to the following conditions:
|
||||||
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
// The above copyright notice and this permission notice shall be included in all
|
||||||
// copies or substantial portions of the Software.
|
// copies or substantial portions of the Software.
|
||||||
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
#ifndef SOL_EBCO_HPP
|
#ifndef SOL_EBCO_HPP
|
||||||
#define SOL_EBCO_HPP
|
#define SOL_EBCO_HPP
|
||||||
|
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
#include <memory>
|
||||||
namespace sol { namespace detail {
|
|
||||||
|
namespace sol { namespace detail {
|
||||||
template <typename T, std::size_t tag = 0, typename = void>
|
|
||||||
struct ebco {
|
template <typename T, std::size_t tag = 0, typename = void>
|
||||||
T m_value;
|
struct ebco {
|
||||||
|
T m_value;
|
||||||
ebco() = default;
|
|
||||||
ebco(const ebco&) = default;
|
ebco() = default;
|
||||||
ebco(ebco&&) = default;
|
ebco(const ebco&) = default;
|
||||||
ebco& operator=(const ebco&) = default;
|
ebco(ebco&&) = default;
|
||||||
ebco& operator=(ebco&&) = default;
|
ebco& operator=(const ebco&) = default;
|
||||||
ebco(const T& v) noexcept(std::is_nothrow_copy_constructible_v<T>) : m_value(v) {};
|
ebco& operator=(ebco&&) = default;
|
||||||
ebco(T&& v) noexcept(std::is_nothrow_move_constructible_v<T>) : m_value(std::move(v)) {};
|
ebco(const T& v) noexcept(std::is_nothrow_copy_constructible_v<T>) : m_value(v) {};
|
||||||
ebco& operator=(const T& v) noexcept(std::is_nothrow_copy_assignable_v<T>) {
|
ebco(T&& v) noexcept(std::is_nothrow_move_constructible_v<T>) : m_value(std::move(v)) {};
|
||||||
m_value = v;
|
ebco& operator=(const T& v) noexcept(std::is_nothrow_copy_assignable_v<T>) {
|
||||||
return *this;
|
m_value = v;
|
||||||
}
|
return *this;
|
||||||
ebco& operator=(T&& v) noexcept(std::is_nothrow_move_assignable_v<T>) {
|
}
|
||||||
m_value = std::move(v);
|
ebco& operator=(T&& v) noexcept(std::is_nothrow_move_assignable_v<T>) {
|
||||||
return *this;
|
m_value = std::move(v);
|
||||||
};
|
return *this;
|
||||||
template <typename Arg, typename... Args,
|
};
|
||||||
typename = std::enable_if_t<
|
template <typename Arg, typename... Args,
|
||||||
!std::is_same_v<std::remove_reference_t<std::remove_cv_t<Arg>>,
|
typename = std::enable_if_t<
|
||||||
ebco> && !std::is_same_v<std::remove_reference_t<std::remove_cv_t<Arg>>, T> && (sizeof...(Args) > 0 || !std::is_convertible_v<Arg, T>)>>
|
!std::is_same_v<std::remove_reference_t<std::remove_cv_t<Arg>>,
|
||||||
ebco(Arg&& arg, Args&&... args) noexcept(std::is_nothrow_constructible_v<T, Arg, Args...>)
|
ebco> && !std::is_same_v<std::remove_reference_t<std::remove_cv_t<Arg>>, T> && (sizeof...(Args) > 0 || !std::is_convertible_v<Arg, T>)>>
|
||||||
: m_value(std::forward<Arg>(arg), std::forward<Args>(args)...) {
|
ebco(Arg&& arg, Args&&... args) noexcept(std::is_nothrow_constructible_v<T, Arg, Args...>)
|
||||||
}
|
: m_value(std::forward<Arg>(arg), std::forward<Args>(args)...) {
|
||||||
|
}
|
||||||
T& value() & noexcept {
|
|
||||||
return m_value;
|
T& value() & noexcept {
|
||||||
}
|
return m_value;
|
||||||
|
}
|
||||||
T const& value() const& noexcept {
|
|
||||||
return m_value;
|
T const& value() const& noexcept {
|
||||||
}
|
return m_value;
|
||||||
|
}
|
||||||
T&& value() && noexcept {
|
|
||||||
return std::move(m_value);
|
T&& value() && noexcept {
|
||||||
}
|
return std::move(m_value);
|
||||||
};
|
}
|
||||||
|
};
|
||||||
template <typename T, std::size_t tag>
|
|
||||||
struct ebco<T, tag, std::enable_if_t<!std::is_reference_v<T> && std::is_class_v<T> && !std::is_final_v<T>>> : T {
|
template <typename T, std::size_t tag>
|
||||||
ebco() = default;
|
struct ebco<T, tag, std::enable_if_t<!std::is_reference_v<T> && std::is_class_v<T> && !std::is_final_v<T>>> : T {
|
||||||
ebco(const ebco&) = default;
|
ebco() = default;
|
||||||
ebco(ebco&&) = default;
|
ebco(const ebco&) = default;
|
||||||
ebco(const T& v) noexcept(std::is_nothrow_copy_constructible_v<T>) : T(v) {};
|
ebco(ebco&&) = default;
|
||||||
ebco(T&& v) noexcept(std::is_nothrow_move_constructible_v<T>) : T(std::move(v)) {};
|
ebco(const T& v) noexcept(std::is_nothrow_copy_constructible_v<T>) : T(v) {};
|
||||||
template <typename Arg, typename... Args,
|
ebco(T&& v) noexcept(std::is_nothrow_move_constructible_v<T>) : T(std::move(v)) {};
|
||||||
typename = std::enable_if_t<
|
template <typename Arg, typename... Args,
|
||||||
!std::is_same_v<std::remove_reference_t<std::remove_cv_t<Arg>>,
|
typename = std::enable_if_t<
|
||||||
ebco> && !std::is_same_v<std::remove_reference_t<std::remove_cv_t<Arg>>, T> && (sizeof...(Args) > 0 || !std::is_convertible_v<Arg, T>)>>
|
!std::is_same_v<std::remove_reference_t<std::remove_cv_t<Arg>>,
|
||||||
ebco(Arg&& arg, Args&&... args) noexcept(std::is_nothrow_constructible_v<T, Arg, Args...>) : T(std::forward<Arg>(arg), std::forward<Args>(args)...) {
|
ebco> && !std::is_same_v<std::remove_reference_t<std::remove_cv_t<Arg>>, T> && (sizeof...(Args) > 0 || !std::is_convertible_v<Arg, T>)>>
|
||||||
}
|
ebco(Arg&& arg, Args&&... args) noexcept(std::is_nothrow_constructible_v<T, Arg, Args...>) : T(std::forward<Arg>(arg), std::forward<Args>(args)...) {
|
||||||
|
}
|
||||||
ebco& operator=(const ebco&) = default;
|
|
||||||
ebco& operator=(ebco&&) = default;
|
ebco& operator=(const ebco&) = default;
|
||||||
ebco& operator=(const T& v) noexcept(std::is_nothrow_copy_assignable_v<T>) {
|
ebco& operator=(ebco&&) = default;
|
||||||
static_cast<T&>(*this) = v;
|
ebco& operator=(const T& v) noexcept(std::is_nothrow_copy_assignable_v<T>) {
|
||||||
return *this;
|
static_cast<T&>(*this) = v;
|
||||||
}
|
return *this;
|
||||||
ebco& operator=(T&& v) noexcept(std::is_nothrow_move_assignable_v<T>) {
|
}
|
||||||
static_cast<T&>(*this) = std::move(v);
|
ebco& operator=(T&& v) noexcept(std::is_nothrow_move_assignable_v<T>) {
|
||||||
return *this;
|
static_cast<T&>(*this) = std::move(v);
|
||||||
};
|
return *this;
|
||||||
|
};
|
||||||
T& value() & noexcept {
|
|
||||||
return static_cast<T&>(*this);
|
T& value() & noexcept {
|
||||||
}
|
return static_cast<T&>(*this);
|
||||||
|
}
|
||||||
T const& value() const& noexcept {
|
|
||||||
return static_cast<T const&>(*this);
|
T const& value() const& noexcept {
|
||||||
}
|
return static_cast<T const&>(*this);
|
||||||
|
}
|
||||||
T&& value() && noexcept {
|
|
||||||
return std::move(static_cast<T&>(*this));
|
T&& value() && noexcept {
|
||||||
}
|
return std::move(static_cast<T&>(*this));
|
||||||
};
|
}
|
||||||
|
};
|
||||||
template <typename T, std::size_t tag>
|
|
||||||
struct ebco<T&, tag> {
|
template <typename T, std::size_t tag>
|
||||||
private:
|
struct ebco<T&, tag> {
|
||||||
T* m_ref;
|
private:
|
||||||
|
T* m_ref;
|
||||||
public:
|
|
||||||
ebco() = default;
|
public:
|
||||||
ebco(const ebco&) = default;
|
ebco() = default;
|
||||||
ebco(ebco&&) = default;
|
ebco(const ebco&) = default;
|
||||||
ebco(T& v) noexcept : m_ref(std::addressof(v)) {};
|
ebco(ebco&&) = default;
|
||||||
|
ebco(T& v) noexcept : m_ref(std::addressof(v)) {};
|
||||||
ebco& operator=(const ebco&) = default;
|
|
||||||
ebco& operator=(ebco&&) = default;
|
ebco& operator=(const ebco&) = default;
|
||||||
ebco& operator=(T& v) noexcept {
|
ebco& operator=(ebco&&) = default;
|
||||||
m_ref = std::addressof(v);
|
ebco& operator=(T& v) noexcept {
|
||||||
return *this;
|
m_ref = std::addressof(v);
|
||||||
}
|
return *this;
|
||||||
|
}
|
||||||
T& value() const noexcept {
|
|
||||||
return *(const_cast<ebco<T&, tag>&>(*this).m_ref);
|
T& value() const noexcept {
|
||||||
}
|
return *(const_cast<ebco<T&, tag>&>(*this).m_ref);
|
||||||
};
|
}
|
||||||
|
};
|
||||||
template <typename T, std::size_t tag>
|
|
||||||
struct ebco<T&&, tag> {
|
template <typename T, std::size_t tag>
|
||||||
T&& ref;
|
struct ebco<T&&, tag> {
|
||||||
|
T&& ref;
|
||||||
ebco() = default;
|
|
||||||
ebco(const ebco&) = delete;
|
ebco() = default;
|
||||||
ebco(ebco&&) = default;
|
ebco(const ebco&) = delete;
|
||||||
ebco(T&& v) noexcept : ref(v) {};
|
ebco(ebco&&) = default;
|
||||||
|
ebco(T&& v) noexcept : ref(v) {};
|
||||||
ebco& operator=(const ebco&) = delete;
|
|
||||||
ebco& operator=(ebco&&) = delete;
|
ebco& operator=(const ebco&) = delete;
|
||||||
|
ebco& operator=(ebco&&) = delete;
|
||||||
T& value() & noexcept {
|
|
||||||
return ref;
|
T& value() & noexcept {
|
||||||
}
|
return ref;
|
||||||
|
}
|
||||||
const T& value() const& noexcept {
|
|
||||||
return ref;
|
const T& value() const& noexcept {
|
||||||
}
|
return ref;
|
||||||
|
}
|
||||||
T&& value() && noexcept {
|
|
||||||
return std::move(ref);
|
T&& value() && noexcept {
|
||||||
}
|
return std::move(ref);
|
||||||
};
|
}
|
||||||
|
};
|
||||||
}} // namespace sol::detail
|
|
||||||
|
}} // namespace sol::detail
|
||||||
#endif // SOL_EBCO_HPP
|
|
||||||
|
#endif // SOL_EBCO_HPP
|
||||||
|
|
|
||||||
23
extern/sol3/sol/environment.hpp
vendored
23
extern/sol3/sol/environment.hpp
vendored
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
// The MIT License (MIT)
|
// The MIT License (MIT)
|
||||||
|
|
||||||
// Copyright (c) 2013-2021 Rapptz, ThePhD and contributors
|
// Copyright (c) 2013-2022 Rapptz, ThePhD and contributors
|
||||||
|
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
// this software and associated documentation files (the "Software"), to deal in
|
// this software and associated documentation files (the "Software"), to deal in
|
||||||
|
|
@ -58,29 +58,29 @@ namespace sol {
|
||||||
|
|
||||||
basic_environment(env_key_t, const stack_reference& extraction_target)
|
basic_environment(env_key_t, const stack_reference& extraction_target)
|
||||||
: base_t(detail::no_safety, extraction_target.lua_state(), (stack::push_environment_of(extraction_target), -1)) {
|
: base_t(detail::no_safety, extraction_target.lua_state(), (stack::push_environment_of(extraction_target), -1)) {
|
||||||
#if SOL_IS_ON(SOL_SAFE_REFERENCES_I_)
|
#if SOL_IS_ON(SOL_SAFE_REFERENCES)
|
||||||
constructor_handler handler {};
|
constructor_handler handler {};
|
||||||
stack::check<env_key_t>(this->lua_state(), -1, handler);
|
stack::check<env_key_t>(this->lua_state(), -1, handler);
|
||||||
#endif // Safety
|
#endif // Safety
|
||||||
lua_pop(this->lua_state(), 2);
|
lua_pop(this->lua_state(), 1);
|
||||||
}
|
}
|
||||||
template <bool b>
|
template <bool b>
|
||||||
basic_environment(env_key_t, const basic_reference<b>& extraction_target)
|
basic_environment(env_key_t, const basic_reference<b>& extraction_target)
|
||||||
: base_t(detail::no_safety, extraction_target.lua_state(), (stack::push_environment_of(extraction_target), -1)) {
|
: base_t(detail::no_safety, extraction_target.lua_state(), (stack::push_environment_of(extraction_target), -1)) {
|
||||||
#if SOL_IS_ON(SOL_SAFE_REFERENCES_I_)
|
#if SOL_IS_ON(SOL_SAFE_REFERENCES)
|
||||||
constructor_handler handler {};
|
constructor_handler handler {};
|
||||||
stack::check<env_key_t>(this->lua_state(), -1, handler);
|
stack::check<env_key_t>(this->lua_state(), -1, handler);
|
||||||
#endif // Safety
|
#endif // Safety
|
||||||
lua_pop(this->lua_state(), 2);
|
lua_pop(this->lua_state(), 1);
|
||||||
}
|
}
|
||||||
basic_environment(lua_State* L, int index = -1) : base_t(detail::no_safety, L, index) {
|
basic_environment(lua_State* L, int index = -1) : base_t(detail::no_safety, L, index) {
|
||||||
#if SOL_IS_ON(SOL_SAFE_REFERENCES_I_)
|
#if SOL_IS_ON(SOL_SAFE_REFERENCES)
|
||||||
constructor_handler handler {};
|
constructor_handler handler {};
|
||||||
stack::check<basic_environment>(L, index, handler);
|
stack::check<basic_environment>(L, index, handler);
|
||||||
#endif // Safety
|
#endif // Safety
|
||||||
}
|
}
|
||||||
basic_environment(lua_State* L, ref_index index) : base_t(detail::no_safety, L, index) {
|
basic_environment(lua_State* L, ref_index index) : base_t(detail::no_safety, L, index) {
|
||||||
#if SOL_IS_ON(SOL_SAFE_REFERENCES_I_)
|
#if SOL_IS_ON(SOL_SAFE_REFERENCES)
|
||||||
auto pp = stack::push_pop(*this);
|
auto pp = stack::push_pop(*this);
|
||||||
constructor_handler handler {};
|
constructor_handler handler {};
|
||||||
stack::check<basic_environment>(L, -1, handler);
|
stack::check<basic_environment>(L, -1, handler);
|
||||||
|
|
@ -90,7 +90,7 @@ namespace sol {
|
||||||
meta::enable<meta::neg<meta::any_same<meta::unqualified_t<T>, basic_environment>>, meta::neg<std::is_same<base_type, stack_reference>>,
|
meta::enable<meta::neg<meta::any_same<meta::unqualified_t<T>, basic_environment>>, meta::neg<std::is_same<base_type, stack_reference>>,
|
||||||
meta::neg<std::is_same<lua_nil_t, meta::unqualified_t<T>>>, is_lua_reference<meta::unqualified_t<T>>> = meta::enabler>
|
meta::neg<std::is_same<lua_nil_t, meta::unqualified_t<T>>>, is_lua_reference<meta::unqualified_t<T>>> = meta::enabler>
|
||||||
basic_environment(T&& r) noexcept : base_t(detail::no_safety, std::forward<T>(r)) {
|
basic_environment(T&& r) noexcept : base_t(detail::no_safety, std::forward<T>(r)) {
|
||||||
#if SOL_IS_ON(SOL_SAFE_REFERENCES_I_)
|
#if SOL_IS_ON(SOL_SAFE_REFERENCES)
|
||||||
if (!is_environment<meta::unqualified_t<T>>::value) {
|
if (!is_environment<meta::unqualified_t<T>>::value) {
|
||||||
auto pp = stack::push_pop(*this);
|
auto pp = stack::push_pop(*this);
|
||||||
constructor_handler handler {};
|
constructor_handler handler {};
|
||||||
|
|
@ -103,7 +103,7 @@ namespace sol {
|
||||||
|
|
||||||
template <typename T, meta::enable<is_lua_reference<meta::unqualified_t<T>>> = meta::enabler>
|
template <typename T, meta::enable<is_lua_reference<meta::unqualified_t<T>>> = meta::enabler>
|
||||||
basic_environment(lua_State* L, T&& r) noexcept : base_t(detail::no_safety, L, std::forward<T>(r)) {
|
basic_environment(lua_State* L, T&& r) noexcept : base_t(detail::no_safety, L, std::forward<T>(r)) {
|
||||||
#if SOL_IS_ON(SOL_SAFE_REFERENCES_I_)
|
#if SOL_IS_ON(SOL_SAFE_REFERENCES)
|
||||||
if (!is_environment<meta::unqualified_t<T>>::value) {
|
if (!is_environment<meta::unqualified_t<T>>::value) {
|
||||||
auto pp = stack::push_pop(*this);
|
auto pp = stack::push_pop(*this);
|
||||||
constructor_handler handler {};
|
constructor_handler handler {};
|
||||||
|
|
@ -136,11 +136,13 @@ namespace sol {
|
||||||
const char* success = lua_setupvalue(L, target_index, 1);
|
const char* success = lua_setupvalue(L, target_index, 1);
|
||||||
if (success == nullptr) {
|
if (success == nullptr) {
|
||||||
// left things alone on the stack, pop them off
|
// left things alone on the stack, pop them off
|
||||||
lua_pop(L, 1);
|
lua_pop(L, 2);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
lua_pop(L, 1);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
lua_pop(L, 1);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
@ -152,6 +154,7 @@ namespace sol {
|
||||||
}
|
}
|
||||||
string_view upvalue_name(maybe_upvalue_name);
|
string_view upvalue_name(maybe_upvalue_name);
|
||||||
if (upvalue_name == "_ENV") {
|
if (upvalue_name == "_ENV") {
|
||||||
|
lua_pop(L, 1);
|
||||||
this->push();
|
this->push();
|
||||||
const char* success = lua_setupvalue(L, target_index, upvalue_index);
|
const char* success = lua_setupvalue(L, target_index, upvalue_index);
|
||||||
if (success == nullptr) {
|
if (success == nullptr) {
|
||||||
|
|
|
||||||
78
extern/sol3/sol/epilogue.hpp
vendored
78
extern/sol3/sol/epilogue.hpp
vendored
|
|
@ -1,39 +1,39 @@
|
||||||
// sol2
|
// sol2
|
||||||
|
|
||||||
// The MIT License (MIT)
|
// The MIT License (MIT)
|
||||||
|
|
||||||
// Copyright (c) 2013-2021 Rapptz, ThePhD and contributors
|
// Copyright (c) 2013-2022 Rapptz, ThePhD and contributors
|
||||||
|
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
// this software and associated documentation files (the "Software"), to deal in
|
// this software and associated documentation files (the "Software"), to deal in
|
||||||
// the Software without restriction, including without limitation the rights to
|
// the Software without restriction, including without limitation the rights to
|
||||||
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||||
// the Software, and to permit persons to whom the Software is furnished to do so,
|
// the Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
// subject to the following conditions:
|
// subject to the following conditions:
|
||||||
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
// The above copyright notice and this permission notice shall be included in all
|
||||||
// copies or substantial portions of the Software.
|
// copies or substantial portions of the Software.
|
||||||
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
|
|
||||||
#if !defined(SOL_PROLOGUE_I_)
|
#if !defined(SOL_PROLOGUE_I_)
|
||||||
#error "[sol2] Library Prologue is missing from this translation unit."
|
#error "[sol2] Library Prologue is missing from this translation unit."
|
||||||
#else
|
#else
|
||||||
#undef SOL_PROLOGUE_I_
|
#undef SOL_PROLOGUE_I_
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if SOL_IS_ON(SOL_BUILD_CXX_MODE_I_)
|
#if SOL_IS_ON(SOL_BUILD_CXX_MODE)
|
||||||
#undef _FWD
|
#undef _FWD
|
||||||
#undef _MOVE
|
#undef _MOVE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
|
||||||
191
extern/sol3/sol/error.hpp
vendored
191
extern/sol3/sol/error.hpp
vendored
|
|
@ -1,89 +1,102 @@
|
||||||
// sol2
|
// sol2
|
||||||
|
|
||||||
// The MIT License (MIT)
|
// The MIT License (MIT)
|
||||||
|
|
||||||
// Copyright (c) 2013-2021 Rapptz, ThePhD and contributors
|
// Copyright (c) 2013-2022 Rapptz, ThePhD and contributors
|
||||||
|
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
// this software and associated documentation files (the "Software"), to deal in
|
// this software and associated documentation files (the "Software"), to deal in
|
||||||
// the Software without restriction, including without limitation the rights to
|
// the Software without restriction, including without limitation the rights to
|
||||||
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||||
// the Software, and to permit persons to whom the Software is furnished to do so,
|
// the Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
// subject to the following conditions:
|
// subject to the following conditions:
|
||||||
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
// The above copyright notice and this permission notice shall be included in all
|
||||||
// copies or substantial portions of the Software.
|
// copies or substantial portions of the Software.
|
||||||
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
#ifndef SOL_ERROR_HPP
|
#ifndef SOL_ERROR_HPP
|
||||||
#define SOL_ERROR_HPP
|
#define SOL_ERROR_HPP
|
||||||
|
|
||||||
#include <sol/compatibility.hpp>
|
#include <sol/compatibility.hpp>
|
||||||
|
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <array>
|
#include <array>
|
||||||
|
|
||||||
namespace sol {
|
namespace sol {
|
||||||
namespace detail {
|
namespace detail {
|
||||||
struct direct_error_tag { };
|
struct direct_error_tag { };
|
||||||
const auto direct_error = direct_error_tag {};
|
const auto direct_error = direct_error_tag {};
|
||||||
|
|
||||||
struct error_result {
|
struct error_result {
|
||||||
int results;
|
int results;
|
||||||
const char* format_string;
|
const char* format_string;
|
||||||
std::array<const char*, 4> argument_strings;
|
std::array<const char*, 4> argument_strings;
|
||||||
|
|
||||||
error_result() : results(0), format_string(nullptr) {
|
error_result() : results(0), format_string(nullptr) {
|
||||||
}
|
}
|
||||||
|
|
||||||
error_result(int results_) : results(results_), format_string(nullptr) {
|
error_result(int results_) : results(results_), format_string(nullptr) {
|
||||||
}
|
}
|
||||||
|
|
||||||
error_result(const char* format_string_, const char* first_message_) : results(0), format_string(format_string_), argument_strings() {
|
error_result(const char* format_string_, const char* first_message_) : results(0), format_string(format_string_), argument_strings() {
|
||||||
argument_strings[0] = first_message_;
|
argument_strings[0] = first_message_;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
inline int handle_errors(lua_State* L, const error_result& er) {
|
inline int handle_errors(lua_State* L, const error_result& er) {
|
||||||
if (er.format_string == nullptr) {
|
if (er.format_string == nullptr) {
|
||||||
return er.results;
|
return er.results;
|
||||||
}
|
}
|
||||||
return luaL_error(L, er.format_string, er.argument_strings[0], er.argument_strings[1], er.argument_strings[2], er.argument_strings[3]);
|
return luaL_error(L, er.format_string, er.argument_strings[0], er.argument_strings[1], er.argument_strings[2], er.argument_strings[3]);
|
||||||
}
|
}
|
||||||
} // namespace detail
|
|
||||||
|
class error_exception : public std::runtime_error {
|
||||||
class error : public std::runtime_error {
|
public:
|
||||||
private:
|
error_exception(const std::string& str) : error_exception(detail::direct_error, "lua: error: " + str) {
|
||||||
// Because VC++ is upsetting, most of the time!
|
}
|
||||||
std::string what_reason;
|
error_exception(std::string&& str) : error_exception(detail::direct_error, "lua: error: " + std::move(str)) {
|
||||||
|
}
|
||||||
public:
|
error_exception(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_exception(detail::direct_error_tag, std::string&& str) : std::runtime_error(str) {
|
||||||
error(std::string&& str) : error(detail::direct_error, "lua: error: " + std::move(str)) {
|
}
|
||||||
}
|
|
||||||
error(detail::direct_error_tag, const std::string& str) : std::runtime_error(""), what_reason(str) {
|
error_exception(const error_exception& e) = default;
|
||||||
}
|
error_exception(error_exception&& e) = default;
|
||||||
error(detail::direct_error_tag, std::string&& str) : std::runtime_error(""), what_reason(std::move(str)) {
|
error_exception& operator=(const error_exception& e) = default;
|
||||||
}
|
error_exception& operator=(error_exception&& e) = default;
|
||||||
|
};
|
||||||
error(const error& e) = default;
|
} // namespace detail
|
||||||
error(error&& e) = default;
|
|
||||||
error& operator=(const error& e) = default;
|
class error : public std::runtime_error {
|
||||||
error& operator=(error&& e) = default;
|
private:
|
||||||
|
// Because VC++ is upsetting, most of the time!
|
||||||
virtual const char* what() const noexcept override {
|
std::string what_reason;
|
||||||
return what_reason.c_str();
|
|
||||||
}
|
public:
|
||||||
};
|
error(const std::string& str) : error(detail::direct_error, "lua: error: " + str) {
|
||||||
|
}
|
||||||
} // namespace sol
|
error(std::string&& str) : error(detail::direct_error, "lua: error: " + std::move(str)) {
|
||||||
|
}
|
||||||
#endif // SOL_ERROR_HPP
|
error(detail::direct_error_tag, const std::string& str) : std::runtime_error(str) {
|
||||||
|
}
|
||||||
|
error(detail::direct_error_tag, std::string&& str) : std::runtime_error(str) {
|
||||||
|
}
|
||||||
|
|
||||||
|
error(const error& e) = default;
|
||||||
|
error(error&& e) = default;
|
||||||
|
error& operator=(const error& e) = default;
|
||||||
|
error& operator=(error&& e) = default;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace sol
|
||||||
|
|
||||||
|
#endif // SOL_ERROR_HPP
|
||||||
|
|
|
||||||
27
extern/sol3/sol/error_handler.hpp
vendored
27
extern/sol3/sol/error_handler.hpp
vendored
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
// The MIT License (MIT)
|
// The MIT License (MIT)
|
||||||
|
|
||||||
// Copyright (c) 2013-2021 Rapptz, ThePhD and contributors
|
// Copyright (c) 2013-2022 Rapptz, ThePhD and contributors
|
||||||
|
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
// this software and associated documentation files (the "Software"), to deal in
|
// this software and associated documentation files (the "Software"), to deal in
|
||||||
|
|
@ -24,6 +24,7 @@
|
||||||
#ifndef SOL_ERROR_HANDLER_HPP
|
#ifndef SOL_ERROR_HANDLER_HPP
|
||||||
#define SOL_ERROR_HANDLER_HPP
|
#define SOL_ERROR_HANDLER_HPP
|
||||||
|
|
||||||
|
#include <sol/config.hpp>
|
||||||
#include <sol/types.hpp>
|
#include <sol/types.hpp>
|
||||||
#include <sol/demangle.hpp>
|
#include <sol/demangle.hpp>
|
||||||
|
|
||||||
|
|
@ -62,7 +63,7 @@ namespace sol {
|
||||||
case type::poly:
|
case type::poly:
|
||||||
return "anything";
|
return "anything";
|
||||||
case type::userdata: {
|
case type::userdata: {
|
||||||
#if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_)
|
#if SOL_IS_ON(SOL_SAFE_STACK_CHECK)
|
||||||
luaL_checkstack(L, 2, "not enough space to push get the type name");
|
luaL_checkstack(L, 2, "not enough space to push get the type name");
|
||||||
#endif // make sure stack doesn't overflow
|
#endif // make sure stack doesn't overflow
|
||||||
if (lua_getmetatable(L, index) == 0) {
|
if (lua_getmetatable(L, index) == 0) {
|
||||||
|
|
@ -84,7 +85,7 @@ namespace sol {
|
||||||
|
|
||||||
inline int push_type_panic_string(lua_State* L, int index, type expected, type actual, string_view message, string_view aux_message) noexcept {
|
inline int push_type_panic_string(lua_State* L, int index, type expected, type actual, string_view message, string_view aux_message) noexcept {
|
||||||
const char* err = message.size() == 0
|
const char* err = message.size() == 0
|
||||||
? (aux_message.size() == 0 ? "stack index %d, expected %s, received %s" : "stack index %d, expected %s, received %s: %s")
|
? (aux_message.size() == 0 ? "stack index %d, expected %s, received %s" : "stack index %d, expected %s, received %s: %s%s")
|
||||||
: "stack index %d, expected %s, received %s: %s %s";
|
: "stack index %d, expected %s, received %s: %s %s";
|
||||||
const char* type_name = expected == type::poly ? "anything" : lua_typename(L, static_cast<int>(expected));
|
const char* type_name = expected == type::poly ? "anything" : lua_typename(L, static_cast<int>(expected));
|
||||||
{
|
{
|
||||||
|
|
@ -96,12 +97,16 @@ namespace sol {
|
||||||
|
|
||||||
inline int type_panic_string(lua_State* L, int index, type expected, type actual, string_view message = "") noexcept(false) {
|
inline int type_panic_string(lua_State* L, int index, type expected, type actual, string_view message = "") noexcept(false) {
|
||||||
push_type_panic_string(L, index, expected, actual, message, "");
|
push_type_panic_string(L, index, expected, actual, message, "");
|
||||||
return lua_error(L);
|
size_t str_size = 0;
|
||||||
|
const char* str = lua_tolstring(L, -1, &str_size);
|
||||||
|
return luaL_error(L, str);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int type_panic_c_str(lua_State* L, int index, type expected, type actual, const char* message = nullptr) noexcept(false) {
|
inline int type_panic_c_str(lua_State* L, int index, type expected, type actual, const char* message = nullptr) noexcept(false) {
|
||||||
push_type_panic_string(L, index, expected, actual, message == nullptr ? "" : message, "");
|
push_type_panic_string(L, index, expected, actual, message == nullptr ? "" : message, "");
|
||||||
return lua_error(L);
|
size_t str_size = 0;
|
||||||
|
const char* str = lua_tolstring(L, -1, &str_size);
|
||||||
|
return luaL_error(L, str);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct type_panic_t {
|
struct type_panic_t {
|
||||||
|
|
@ -118,7 +123,9 @@ namespace sol {
|
||||||
struct constructor_handler {
|
struct constructor_handler {
|
||||||
int operator()(lua_State* L, int index, type expected, type actual, string_view message) const noexcept(false) {
|
int operator()(lua_State* L, int index, type expected, type actual, string_view message) const noexcept(false) {
|
||||||
push_type_panic_string(L, index, expected, actual, message, "(type check failed in constructor)");
|
push_type_panic_string(L, index, expected, actual, message, "(type check failed in constructor)");
|
||||||
return lua_error(L);
|
size_t str_size = 0;
|
||||||
|
const char* str = lua_tolstring(L, -1, &str_size);
|
||||||
|
return luaL_error(L, str);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -126,7 +133,9 @@ namespace sol {
|
||||||
struct argument_handler {
|
struct argument_handler {
|
||||||
int operator()(lua_State* L, int index, type expected, type actual, string_view message) const noexcept(false) {
|
int operator()(lua_State* L, int index, type expected, type actual, string_view message) const noexcept(false) {
|
||||||
push_type_panic_string(L, index, expected, actual, message, "(bad argument to variable or function call)");
|
push_type_panic_string(L, index, expected, actual, message, "(bad argument to variable or function call)");
|
||||||
return lua_error(L);
|
size_t str_size = 0;
|
||||||
|
const char* str = lua_tolstring(L, -1, &str_size);
|
||||||
|
return luaL_error(L, str);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -142,7 +151,9 @@ namespace sol {
|
||||||
aux_message += ")')";
|
aux_message += ")')";
|
||||||
push_type_panic_string(L, index, expected, actual, message, aux_message);
|
push_type_panic_string(L, index, expected, actual, message, aux_message);
|
||||||
}
|
}
|
||||||
return lua_error(L);
|
size_t str_size = 0;
|
||||||
|
const char* str = lua_tolstring(L, -1, &str_size);
|
||||||
|
return luaL_error(L, str);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
14
extern/sol3/sol/forward.hpp
vendored
14
extern/sol3/sol/forward.hpp
vendored
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
// The MIT License (MIT)
|
// The MIT License (MIT)
|
||||||
|
|
||||||
// Copyright (c) 2013-2021 Rapptz, ThePhD and contributors
|
// Copyright (c) 2013-2022 Rapptz, ThePhD and contributors
|
||||||
|
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
// this software and associated documentation files (the "Software"), to deal in
|
// this software and associated documentation files (the "Software"), to deal in
|
||||||
|
|
@ -30,7 +30,7 @@
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <string_view>
|
#include <string_view>
|
||||||
|
|
||||||
#if SOL_IS_ON(SOL_USE_CXX_LUA_I_) || SOL_IS_ON(SOL_USE_CXX_LUAJIT_I_)
|
#if SOL_IS_ON(SOL_USING_CXX_LUA) || SOL_IS_ON(SOL_USING_CXX_LUAJIT)
|
||||||
struct lua_State;
|
struct lua_State;
|
||||||
#else
|
#else
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
@ -117,7 +117,7 @@ namespace sol {
|
||||||
using main_protected_function = main_safe_function;
|
using main_protected_function = main_safe_function;
|
||||||
using stack_protected_function = stack_safe_function;
|
using stack_protected_function = stack_safe_function;
|
||||||
using stack_aligned_protected_function = stack_aligned_safe_function;
|
using stack_aligned_protected_function = stack_aligned_safe_function;
|
||||||
#if SOL_IS_ON(SOL_SAFE_FUNCTION_OBJECTS_I_)
|
#if SOL_IS_ON(SOL_SAFE_FUNCTION_OBJECTS)
|
||||||
using function = protected_function;
|
using function = protected_function;
|
||||||
using main_function = main_protected_function;
|
using main_function = main_protected_function;
|
||||||
using stack_function = stack_protected_function;
|
using stack_function = stack_protected_function;
|
||||||
|
|
@ -133,7 +133,7 @@ namespace sol {
|
||||||
struct unsafe_function_result;
|
struct unsafe_function_result;
|
||||||
struct protected_function_result;
|
struct protected_function_result;
|
||||||
using safe_function_result = protected_function_result;
|
using safe_function_result = protected_function_result;
|
||||||
#if SOL_IS_ON(SOL_SAFE_FUNCTION_OBJECTS_I_)
|
#if SOL_IS_ON(SOL_SAFE_FUNCTION_OBJECTS)
|
||||||
using function_result = safe_function_result;
|
using function_result = safe_function_result;
|
||||||
#else
|
#else
|
||||||
using function_result = unsafe_function_result;
|
using function_result = unsafe_function_result;
|
||||||
|
|
@ -234,7 +234,7 @@ namespace sol {
|
||||||
struct record;
|
struct record;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if SOL_IS_OFF(SOL_USE_BOOST_I_)
|
#if SOL_IS_OFF(SOL_USE_BOOST)
|
||||||
template <class T>
|
template <class T>
|
||||||
class optional;
|
class optional;
|
||||||
|
|
||||||
|
|
@ -253,7 +253,7 @@ namespace sol {
|
||||||
typedef ::sol::types<__VA_ARGS__> type; \
|
typedef ::sol::types<__VA_ARGS__> type; \
|
||||||
}; \
|
}; \
|
||||||
} \
|
} \
|
||||||
void a_sol3_detail_function_decl_please_no_collide()
|
static_assert(true, "")
|
||||||
#define SOL_DERIVED_CLASSES(T, ...) \
|
#define SOL_DERIVED_CLASSES(T, ...) \
|
||||||
namespace sol { \
|
namespace sol { \
|
||||||
template <> \
|
template <> \
|
||||||
|
|
@ -261,6 +261,6 @@ namespace sol {
|
||||||
typedef ::sol::types<__VA_ARGS__> type; \
|
typedef ::sol::types<__VA_ARGS__> type; \
|
||||||
}; \
|
}; \
|
||||||
} \
|
} \
|
||||||
void a_sol3_detail_function_decl_please_no_collide()
|
static_assert(true, "")
|
||||||
|
|
||||||
#endif // SOL_FORWARD_HPP
|
#endif // SOL_FORWARD_HPP
|
||||||
|
|
|
||||||
44
extern/sol3/sol/forward_as.hpp
vendored
Normal file
44
extern/sol3/sol/forward_as.hpp
vendored
Normal file
|
|
@ -0,0 +1,44 @@
|
||||||
|
// sol2
|
||||||
|
|
||||||
|
// The MIT License (MIT)
|
||||||
|
|
||||||
|
// Copyright (c) 2013-2022 Rapptz, ThePhD and contributors
|
||||||
|
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
|
// this software and associated documentation files (the "Software"), to deal in
|
||||||
|
// the Software without restriction, including without limitation the rights to
|
||||||
|
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||||
|
// the Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
|
// subject to the following conditions:
|
||||||
|
|
||||||
|
// The above copyright notice and this permission notice shall be included in all
|
||||||
|
// copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
#ifndef SOL_FORWARD_AS_HPP
|
||||||
|
#define SOL_FORWARD_AS_HPP
|
||||||
|
|
||||||
|
#include <sol/version.hpp>
|
||||||
|
|
||||||
|
#include <utility>
|
||||||
|
#include <type_traits>
|
||||||
|
|
||||||
|
namespace sol {
|
||||||
|
template <typename T, typename U>
|
||||||
|
constexpr decltype(auto) forward_as(U&& value) noexcept {
|
||||||
|
if constexpr (::std::is_lvalue_reference_v<T>) {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return ::std::move(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // SOL_FORWARD_AS_HPP
|
||||||
4
extern/sol3/sol/forward_detail.hpp
vendored
4
extern/sol3/sol/forward_detail.hpp
vendored
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
// The MIT License (MIT)
|
// The MIT License (MIT)
|
||||||
|
|
||||||
// Copyright (c) 2013-2021 Rapptz, ThePhD and contributors
|
// Copyright (c) 2013-2022 Rapptz, ThePhD and contributors
|
||||||
|
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
// this software and associated documentation files (the "Software"), to deal in
|
// this software and associated documentation files (the "Software"), to deal in
|
||||||
|
|
@ -32,7 +32,7 @@
|
||||||
namespace sol {
|
namespace sol {
|
||||||
namespace detail {
|
namespace detail {
|
||||||
const bool default_safe_function_calls =
|
const bool default_safe_function_calls =
|
||||||
#if SOL_IS_ON(SOL_SAFE_FUNCTION_CALLS_I_)
|
#if SOL_IS_ON(SOL_SAFE_FUNCTION_CALLS)
|
||||||
true;
|
true;
|
||||||
#else
|
#else
|
||||||
false;
|
false;
|
||||||
|
|
|
||||||
284
extern/sol3/sol/function.hpp
vendored
284
extern/sol3/sol/function.hpp
vendored
|
|
@ -1,142 +1,142 @@
|
||||||
// sol2
|
// sol2
|
||||||
|
|
||||||
// The MIT License (MIT)
|
// The MIT License (MIT)
|
||||||
|
|
||||||
// Copyright (c) 2013-2021 Rapptz, ThePhD and contributors
|
// Copyright (c) 2013-2022 Rapptz, ThePhD and contributors
|
||||||
|
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
// this software and associated documentation files (the "Software"), to deal in
|
// this software and associated documentation files (the "Software"), to deal in
|
||||||
// the Software without restriction, including without limitation the rights to
|
// the Software without restriction, including without limitation the rights to
|
||||||
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||||
// the Software, and to permit persons to whom the Software is furnished to do so,
|
// the Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
// subject to the following conditions:
|
// subject to the following conditions:
|
||||||
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
// The above copyright notice and this permission notice shall be included in all
|
||||||
// copies or substantial portions of the Software.
|
// copies or substantial portions of the Software.
|
||||||
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
#ifndef SOL_FUNCTION_HPP
|
#ifndef SOL_FUNCTION_HPP
|
||||||
#define SOL_FUNCTION_HPP
|
#define SOL_FUNCTION_HPP
|
||||||
|
|
||||||
#include <sol/stack.hpp>
|
#include <sol/stack.hpp>
|
||||||
#include <sol/unsafe_function.hpp>
|
#include <sol/unsafe_function.hpp>
|
||||||
#include <sol/protected_function.hpp>
|
#include <sol/protected_function.hpp>
|
||||||
#include <sol/bytecode.hpp>
|
#include <sol/bytecode.hpp>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
namespace sol {
|
namespace sol {
|
||||||
template <typename... Ret, typename... Args>
|
template <typename... Ret, typename... Args>
|
||||||
decltype(auto) stack_proxy::call(Args&&... args) {
|
decltype(auto) stack_proxy::call(Args&&... args) {
|
||||||
stack_function sf(this->lua_state(), this->stack_index());
|
stack_function sf(this->lua_state(), this->stack_index());
|
||||||
return sf.template call<Ret...>(std::forward<Args>(args)...);
|
return sf.template call<Ret...>(std::forward<Args>(args)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline protected_function_result::protected_function_result(unsafe_function_result&& o) noexcept
|
inline protected_function_result::protected_function_result(unsafe_function_result&& o) noexcept
|
||||||
: L(o.lua_state()), index(o.stack_index()), returncount(o.return_count()), popcount(o.return_count()), err(o.status()) {
|
: L(o.lua_state()), index(o.stack_index()), returncount(o.return_count()), popcount(o.return_count()), err(o.status()) {
|
||||||
// Must be manual, otherwise destructor will screw us
|
// Must be manual, otherwise destructor will screw us
|
||||||
// return count being 0 is enough to keep things clean
|
// return count being 0 is enough to keep things clean
|
||||||
// but we will be thorough
|
// but we will be thorough
|
||||||
o.abandon();
|
o.abandon();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline protected_function_result& protected_function_result::operator=(unsafe_function_result&& o) noexcept {
|
inline protected_function_result& protected_function_result::operator=(unsafe_function_result&& o) noexcept {
|
||||||
L = o.lua_state();
|
L = o.lua_state();
|
||||||
index = o.stack_index();
|
index = o.stack_index();
|
||||||
returncount = o.return_count();
|
returncount = o.return_count();
|
||||||
popcount = o.return_count();
|
popcount = o.return_count();
|
||||||
err = o.status();
|
err = o.status();
|
||||||
// Must be manual, otherwise destructor will screw us
|
// Must be manual, otherwise destructor will screw us
|
||||||
// return count being 0 is enough to keep things clean
|
// return count being 0 is enough to keep things clean
|
||||||
// but we will be thorough
|
// but we will be thorough
|
||||||
o.abandon();
|
o.abandon();
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline unsafe_function_result::unsafe_function_result(protected_function_result&& o) noexcept
|
inline unsafe_function_result::unsafe_function_result(protected_function_result&& o) noexcept
|
||||||
: L(o.lua_state()), index(o.stack_index()), returncount(o.return_count()) {
|
: L(o.lua_state()), index(o.stack_index()), returncount(o.return_count()) {
|
||||||
// Must be manual, otherwise destructor will screw us
|
// Must be manual, otherwise destructor will screw us
|
||||||
// return count being 0 is enough to keep things clean
|
// return count being 0 is enough to keep things clean
|
||||||
// but we will be thorough
|
// but we will be thorough
|
||||||
o.abandon();
|
o.abandon();
|
||||||
}
|
}
|
||||||
inline unsafe_function_result& unsafe_function_result::operator=(protected_function_result&& o) noexcept {
|
inline unsafe_function_result& unsafe_function_result::operator=(protected_function_result&& o) noexcept {
|
||||||
L = o.lua_state();
|
L = o.lua_state();
|
||||||
index = o.stack_index();
|
index = o.stack_index();
|
||||||
returncount = o.return_count();
|
returncount = o.return_count();
|
||||||
// Must be manual, otherwise destructor will screw us
|
// Must be manual, otherwise destructor will screw us
|
||||||
// return count being 0 is enough to keep things clean
|
// return count being 0 is enough to keep things clean
|
||||||
// but we will be thorough
|
// but we will be thorough
|
||||||
o.abandon();
|
o.abandon();
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace detail {
|
namespace detail {
|
||||||
template <typename... R>
|
template <typename... R>
|
||||||
struct std_shim {
|
struct std_shim {
|
||||||
unsafe_function lua_func_;
|
unsafe_function lua_func_;
|
||||||
|
|
||||||
std_shim(unsafe_function lua_func) : lua_func_(std::move(lua_func)) {
|
std_shim(unsafe_function lua_func) : lua_func_(std::move(lua_func)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename... Args>
|
template <typename... Args>
|
||||||
meta::return_type_t<R...> operator()(Args&&... args) {
|
meta::return_type_t<R...> operator()(Args&&... args) {
|
||||||
return lua_func_.call<R...>(std::forward<Args>(args)...);
|
return lua_func_.call<R...>(std::forward<Args>(args)...);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct std_shim<void> {
|
struct std_shim<void> {
|
||||||
unsafe_function lua_func_;
|
unsafe_function lua_func_;
|
||||||
|
|
||||||
std_shim(unsafe_function lua_func) : lua_func_(std::move(lua_func)) {
|
std_shim(unsafe_function lua_func) : lua_func_(std::move(lua_func)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename... Args>
|
template <typename... Args>
|
||||||
void operator()(Args&&... args) {
|
void operator()(Args&&... args) {
|
||||||
lua_func_.call<void>(std::forward<Args>(args)...);
|
lua_func_.call<void>(std::forward<Args>(args)...);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
|
|
||||||
namespace stack {
|
namespace stack {
|
||||||
template <typename Signature>
|
template <typename Signature>
|
||||||
struct unqualified_getter<std::function<Signature>> {
|
struct unqualified_getter<std::function<Signature>> {
|
||||||
typedef meta::bind_traits<Signature> fx_t;
|
typedef meta::bind_traits<Signature> fx_t;
|
||||||
typedef typename fx_t::args_list args_lists;
|
typedef typename fx_t::args_list args_lists;
|
||||||
typedef meta::tuple_types<typename fx_t::return_type> return_types;
|
typedef meta::tuple_types<typename fx_t::return_type> return_types;
|
||||||
|
|
||||||
template <typename... R>
|
template <typename... R>
|
||||||
static std::function<Signature> get_std_func(types<R...>, lua_State* L, int index) {
|
static std::function<Signature> get_std_func(types<R...>, lua_State* L, int index) {
|
||||||
detail::std_shim<R...> fx(unsafe_function(L, index));
|
detail::std_shim<R...> fx(unsafe_function(L, index));
|
||||||
return fx;
|
return fx;
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::function<Signature> get(lua_State* L, int index, record& tracking) {
|
static std::function<Signature> get(lua_State* L, int index, record& tracking) {
|
||||||
tracking.use(1);
|
tracking.use(1);
|
||||||
type t = type_of(L, index);
|
type t = type_of(L, index);
|
||||||
if (t == type::none || t == type::lua_nil) {
|
if (t == type::none || t == type::lua_nil) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
return get_std_func(return_types(), L, index);
|
return get_std_func(return_types(), L, index);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename Allocator>
|
template <typename Allocator>
|
||||||
struct unqualified_getter<basic_bytecode<Allocator>> {
|
struct unqualified_getter<basic_bytecode<Allocator>> {
|
||||||
static basic_bytecode<Allocator> get(lua_State* L, int index, record& tracking) {
|
static basic_bytecode<Allocator> get(lua_State* L, int index, record& tracking) {
|
||||||
tracking.use(1);
|
tracking.use(1);
|
||||||
stack_function sf(L, index);
|
stack_function sf(L, index);
|
||||||
return sf.dump(&dump_panic_on_error);
|
return sf.dump(&dump_panic_on_error);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} // namespace stack
|
} // namespace stack
|
||||||
|
|
||||||
} // namespace sol
|
} // namespace sol
|
||||||
|
|
||||||
#endif // SOL_FUNCTION_HPP
|
#endif // SOL_FUNCTION_HPP
|
||||||
|
|
|
||||||
2
extern/sol3/sol/function_result.hpp
vendored
2
extern/sol3/sol/function_result.hpp
vendored
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
// The MIT License (MIT)
|
// The MIT License (MIT)
|
||||||
|
|
||||||
// Copyright (c) 2013-2021 Rapptz, ThePhD and contributors
|
// Copyright (c) 2013-2022 Rapptz, ThePhD and contributors
|
||||||
|
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
// this software and associated documentation files (the "Software"), to deal in
|
// this software and associated documentation files (the "Software"), to deal in
|
||||||
|
|
|
||||||
14
extern/sol3/sol/function_types.hpp
vendored
14
extern/sol3/sol/function_types.hpp
vendored
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
// The MIT License (MIT)
|
// The MIT License (MIT)
|
||||||
|
|
||||||
// Copyright (c) 2013-2021 Rapptz, ThePhD and contributors
|
// Copyright (c) 2013-2022 Rapptz, ThePhD and contributors
|
||||||
|
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
// this software and associated documentation files (the "Software"), to deal in
|
// this software and associated documentation files (the "Software"), to deal in
|
||||||
|
|
@ -217,7 +217,7 @@ namespace sol {
|
||||||
int upvalues = 0;
|
int upvalues = 0;
|
||||||
upvalues += stack::push(L, nullptr);
|
upvalues += stack::push(L, nullptr);
|
||||||
upvalues += stack::push(L, std::forward<Fx>(fx));
|
upvalues += stack::push(L, std::forward<Fx>(fx));
|
||||||
#if SOL_IS_ON(SOL_USE_NOEXCEPT_FUNCTION_TYPE_I_)
|
#if SOL_IS_ON(SOL_USE_NOEXCEPT_FUNCTION_TYPE)
|
||||||
if constexpr (std::is_nothrow_invocable_r_v<int, uFx, lua_State*>) {
|
if constexpr (std::is_nothrow_invocable_r_v<int, uFx, lua_State*>) {
|
||||||
detail::lua_CFunction_noexcept cf = &lua_c_noexcept_wrapper<true>;
|
detail::lua_CFunction_noexcept cf = &lua_c_noexcept_wrapper<true>;
|
||||||
lua_pushcclosure(L, reinterpret_cast<lua_CFunction>(cf), upvalues);
|
lua_pushcclosure(L, reinterpret_cast<lua_CFunction>(cf), upvalues);
|
||||||
|
|
@ -237,7 +237,7 @@ namespace sol {
|
||||||
int upvalues = 0;
|
int upvalues = 0;
|
||||||
upvalues += stack::push(L, nullptr);
|
upvalues += stack::push(L, nullptr);
|
||||||
upvalues += stack::push(L, std::forward<Fx>(fx));
|
upvalues += stack::push(L, std::forward<Fx>(fx));
|
||||||
#if SOL_IS_ON(SOL_USE_NOEXCEPT_FUNCTION_TYPE_I_)
|
#if SOL_IS_ON(SOL_USE_NOEXCEPT_FUNCTION_TYPE)
|
||||||
if constexpr (std::is_nothrow_invocable_r_v<int, uFx, lua_State*>) {
|
if constexpr (std::is_nothrow_invocable_r_v<int, uFx, lua_State*>) {
|
||||||
detail::lua_CFunction_noexcept cf = &lua_c_noexcept_wrapper<is_yielding>;
|
detail::lua_CFunction_noexcept cf = &lua_c_noexcept_wrapper<is_yielding>;
|
||||||
lua_pushcclosure(L, reinterpret_cast<lua_CFunction>(cf), upvalues);
|
lua_pushcclosure(L, reinterpret_cast<lua_CFunction>(cf), upvalues);
|
||||||
|
|
@ -398,7 +398,7 @@ namespace sol {
|
||||||
struct unqualified_pusher<Signature,
|
struct unqualified_pusher<Signature,
|
||||||
std::enable_if_t<meta::all<std::is_function<std::remove_pointer_t<Signature>>, meta::neg<std::is_same<Signature, lua_CFunction>>,
|
std::enable_if_t<meta::all<std::is_function<std::remove_pointer_t<Signature>>, meta::neg<std::is_same<Signature, lua_CFunction>>,
|
||||||
meta::neg<std::is_same<Signature, std::remove_pointer_t<lua_CFunction>>>
|
meta::neg<std::is_same<Signature, std::remove_pointer_t<lua_CFunction>>>
|
||||||
#if SOL_IS_ON(SOL_USE_NOEXCEPT_FUNCTION_TYPE_I_)
|
#if SOL_IS_ON(SOL_USE_NOEXCEPT_FUNCTION_TYPE)
|
||||||
,
|
,
|
||||||
meta::neg<std::is_same<Signature, detail::lua_CFunction_noexcept>>,
|
meta::neg<std::is_same<Signature, detail::lua_CFunction_noexcept>>,
|
||||||
meta::neg<std::is_same<Signature, std::remove_pointer_t<detail::lua_CFunction_noexcept>>>
|
meta::neg<std::is_same<Signature, std::remove_pointer_t<detail::lua_CFunction_noexcept>>>
|
||||||
|
|
@ -711,7 +711,7 @@ namespace sol {
|
||||||
namespace stack_detail {
|
namespace stack_detail {
|
||||||
template <typename Function, typename Handler>
|
template <typename Function, typename Handler>
|
||||||
bool check_function_pointer(lua_State* L, int index, Handler&& handler, record& tracking) noexcept {
|
bool check_function_pointer(lua_State* L, int index, Handler&& handler, record& tracking) noexcept {
|
||||||
#if SOL_IS_ON(SOL_GET_FUNCTION_POINTER_UNSAFE_I_)
|
#if SOL_IS_ON(SOL_GET_FUNCTION_POINTER_UNSAFE)
|
||||||
tracking.use(1);
|
tracking.use(1);
|
||||||
bool success = lua_iscfunction(L, index) == 1;
|
bool success = lua_iscfunction(L, index) == 1;
|
||||||
if (success) {
|
if (success) {
|
||||||
|
|
@ -737,7 +737,7 @@ namespace sol {
|
||||||
|
|
||||||
template <typename Function>
|
template <typename Function>
|
||||||
Function* get_function_pointer(lua_State* L, int index, record& tracking) noexcept {
|
Function* get_function_pointer(lua_State* L, int index, record& tracking) noexcept {
|
||||||
#if SOL_IS_ON(SOL_GET_FUNCTION_POINTER_UNSAFE_I_)
|
#if SOL_IS_ON(SOL_GET_FUNCTION_POINTER_UNSAFE)
|
||||||
tracking.use(1);
|
tracking.use(1);
|
||||||
auto udata = stack::stack_detail::get_as_upvalues_using_function<Function*>(L, index);
|
auto udata = stack::stack_detail::get_as_upvalues_using_function<Function*>(L, index);
|
||||||
Function* fx = udata.first;
|
Function* fx = udata.first;
|
||||||
|
|
@ -747,7 +747,7 @@ namespace sol {
|
||||||
(void)index;
|
(void)index;
|
||||||
(void)tracking;
|
(void)tracking;
|
||||||
static_assert(meta::meta_detail::always_true<Function>::value,
|
static_assert(meta::meta_detail::always_true<Function>::value,
|
||||||
#if SOL_IS_DEFAULT_OFF(SOL_GET_FUNCTION_POINTER_UNSAFE_I_)
|
#if SOL_IS_DEFAULT_OFF(SOL_GET_FUNCTION_POINTER_UNSAFE)
|
||||||
"You are attempting to retrieve a function pointer type. "
|
"You are attempting to retrieve a function pointer type. "
|
||||||
"This is inherently unsafe in sol2. In order to do this, you must turn on the "
|
"This is inherently unsafe in sol2. In order to do this, you must turn on the "
|
||||||
"SOL_GET_FUNCTION_POINTER_UNSAFE configuration macro, as detailed in the documentation. "
|
"SOL_GET_FUNCTION_POINTER_UNSAFE configuration macro, as detailed in the documentation. "
|
||||||
|
|
|
||||||
2
extern/sol3/sol/function_types_core.hpp
vendored
2
extern/sol3/sol/function_types_core.hpp
vendored
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
// The MIT License (MIT)
|
// The MIT License (MIT)
|
||||||
|
|
||||||
// Copyright (c) 2013-2021 Rapptz, ThePhD and contributors
|
// Copyright (c) 2013-2022 Rapptz, ThePhD and contributors
|
||||||
|
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
// this software and associated documentation files (the "Software"), to deal in
|
// this software and associated documentation files (the "Software"), to deal in
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
// The MIT License (MIT)
|
// The MIT License (MIT)
|
||||||
|
|
||||||
// Copyright (c) 2013-2021 Rapptz, ThePhD and contributors
|
// Copyright (c) 2013-2022 Rapptz, ThePhD and contributors
|
||||||
|
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
// this software and associated documentation files (the "Software"), to deal in
|
// this software and associated documentation files (the "Software"), to deal in
|
||||||
|
|
@ -62,4 +62,4 @@ namespace sol { namespace function_detail {
|
||||||
};
|
};
|
||||||
}} // namespace sol::function_detail
|
}} // namespace sol::function_detail
|
||||||
|
|
||||||
#endif // SOL_FUNCTION_TYPES_OVERLOAD_HPP
|
#endif // SOL_FUNCTION_TYPES_OVERLOAD_HPP
|
||||||
|
|
|
||||||
6
extern/sol3/sol/function_types_stateful.hpp
vendored
6
extern/sol3/sol/function_types_stateful.hpp
vendored
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
// The MIT License (MIT)
|
// The MIT License (MIT)
|
||||||
|
|
||||||
// Copyright (c) 2013-2021 Rapptz, ThePhD and contributors
|
// Copyright (c) 2013-2022 Rapptz, ThePhD and contributors
|
||||||
|
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
// this software and associated documentation files (the "Software"), to deal in
|
// this software and associated documentation files (the "Software"), to deal in
|
||||||
|
|
@ -74,7 +74,7 @@ namespace sol { namespace function_detail {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int call(lua_State* L, member_function& self)
|
static int call(lua_State* L, member_function& self)
|
||||||
#if SOL_IS_ON(SOL_COMPILER_VCXX_I_)
|
#if SOL_IS_ON(SOL_COMPILER_VCXX)
|
||||||
// MSVC is broken, what a surprise...
|
// MSVC is broken, what a surprise...
|
||||||
#else
|
#else
|
||||||
noexcept(traits_type::is_noexcept)
|
noexcept(traits_type::is_noexcept)
|
||||||
|
|
@ -90,7 +90,7 @@ namespace sol { namespace function_detail {
|
||||||
}
|
}
|
||||||
|
|
||||||
int operator()(lua_State* L)
|
int operator()(lua_State* L)
|
||||||
#if SOL_IS_ON(SOL_COMPILER_VCXX_I_)
|
#if SOL_IS_ON(SOL_COMPILER_VCXX)
|
||||||
// MSVC is broken, what a surprise...
|
// MSVC is broken, what a surprise...
|
||||||
#else
|
#else
|
||||||
noexcept(traits_type::is_noexcept)
|
noexcept(traits_type::is_noexcept)
|
||||||
|
|
|
||||||
44
extern/sol3/sol/function_types_stateless.hpp
vendored
44
extern/sol3/sol/function_types_stateless.hpp
vendored
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
// The MIT License (MIT)
|
// The MIT License (MIT)
|
||||||
|
|
||||||
// Copyright (c) 2013-2021 Rapptz, ThePhD and contributors
|
// Copyright (c) 2013-2022 Rapptz, ThePhD and contributors
|
||||||
|
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
// this software and associated documentation files (the "Software"), to deal in
|
// this software and associated documentation files (the "Software"), to deal in
|
||||||
|
|
@ -35,7 +35,7 @@ namespace sol { namespace function_detail {
|
||||||
using traits_type = meta::bind_traits<function_type>;
|
using traits_type = meta::bind_traits<function_type>;
|
||||||
|
|
||||||
static int real_call(lua_State* L)
|
static int real_call(lua_State* L)
|
||||||
#if SOL_IS_ON(SOL_COMPILER_VCXX_I_)
|
#if SOL_IS_ON(SOL_COMPILER_VCXX)
|
||||||
// MSVC is broken, what a surprise...
|
// MSVC is broken, what a surprise...
|
||||||
#else
|
#else
|
||||||
noexcept(traits_type::is_noexcept)
|
noexcept(traits_type::is_noexcept)
|
||||||
|
|
@ -70,7 +70,7 @@ namespace sol { namespace function_detail {
|
||||||
typedef lua_bind_traits<function_type> traits_type;
|
typedef lua_bind_traits<function_type> traits_type;
|
||||||
|
|
||||||
static int real_call(lua_State* L)
|
static int real_call(lua_State* L)
|
||||||
#if SOL_IS_ON(SOL_COMPILER_VCXX_I_)
|
#if SOL_IS_ON(SOL_COMPILER_VCXX)
|
||||||
// MSVC is broken, what a surprise...
|
// MSVC is broken, what a surprise...
|
||||||
#else
|
#else
|
||||||
noexcept(traits_type::is_noexcept)
|
noexcept(traits_type::is_noexcept)
|
||||||
|
|
@ -88,7 +88,7 @@ namespace sol { namespace function_detail {
|
||||||
|
|
||||||
template <bool is_yielding, bool no_trampoline>
|
template <bool is_yielding, bool no_trampoline>
|
||||||
static int call(lua_State* L)
|
static int call(lua_State* L)
|
||||||
#if SOL_IS_ON(SOL_COMPILER_VCXX_I_)
|
#if SOL_IS_ON(SOL_COMPILER_VCXX)
|
||||||
// MSVC is broken, what a surprise...
|
// MSVC is broken, what a surprise...
|
||||||
#else
|
#else
|
||||||
noexcept(traits_type::is_noexcept)
|
noexcept(traits_type::is_noexcept)
|
||||||
|
|
@ -110,7 +110,7 @@ namespace sol { namespace function_detail {
|
||||||
}
|
}
|
||||||
|
|
||||||
int operator()(lua_State* L)
|
int operator()(lua_State* L)
|
||||||
#if SOL_IS_ON(SOL_COMPILER_VCXX_I_)
|
#if SOL_IS_ON(SOL_COMPILER_VCXX)
|
||||||
// MSVC is broken, what a surprise...
|
// MSVC is broken, what a surprise...
|
||||||
#else
|
#else
|
||||||
noexcept(traits_type::is_noexcept)
|
noexcept(traits_type::is_noexcept)
|
||||||
|
|
@ -126,7 +126,7 @@ namespace sol { namespace function_detail {
|
||||||
typedef lua_bind_traits<function_type> traits_type;
|
typedef lua_bind_traits<function_type> traits_type;
|
||||||
|
|
||||||
static int real_call(lua_State* L)
|
static int real_call(lua_State* L)
|
||||||
#if SOL_IS_ON(SOL_COMPILER_VCXX_I_)
|
#if SOL_IS_ON(SOL_COMPILER_VCXX)
|
||||||
// MSVC is broken, what a surprise...
|
// MSVC is broken, what a surprise...
|
||||||
#else
|
#else
|
||||||
noexcept(traits_type::is_noexcept)
|
noexcept(traits_type::is_noexcept)
|
||||||
|
|
@ -153,7 +153,7 @@ namespace sol { namespace function_detail {
|
||||||
|
|
||||||
template <bool is_yielding, bool no_trampoline>
|
template <bool is_yielding, bool no_trampoline>
|
||||||
static int call(lua_State* L)
|
static int call(lua_State* L)
|
||||||
#if SOL_IS_ON(SOL_COMPILER_VCXX_I_)
|
#if SOL_IS_ON(SOL_COMPILER_VCXX)
|
||||||
// MSVC is broken, what a surprise...
|
// MSVC is broken, what a surprise...
|
||||||
#else
|
#else
|
||||||
noexcept(traits_type::is_noexcept)
|
noexcept(traits_type::is_noexcept)
|
||||||
|
|
@ -175,7 +175,7 @@ namespace sol { namespace function_detail {
|
||||||
}
|
}
|
||||||
|
|
||||||
int operator()(lua_State* L)
|
int operator()(lua_State* L)
|
||||||
#if SOL_IS_ON(SOL_COMPILER_VCXX_I_)
|
#if SOL_IS_ON(SOL_COMPILER_VCXX)
|
||||||
// MSVC is broken, what a surprise...
|
// MSVC is broken, what a surprise...
|
||||||
#else
|
#else
|
||||||
noexcept(traits_type::is_noexcept)
|
noexcept(traits_type::is_noexcept)
|
||||||
|
|
@ -191,7 +191,7 @@ namespace sol { namespace function_detail {
|
||||||
typedef lua_bind_traits<function_type> traits_type;
|
typedef lua_bind_traits<function_type> traits_type;
|
||||||
|
|
||||||
static int real_call(lua_State* L)
|
static int real_call(lua_State* L)
|
||||||
#if SOL_IS_ON(SOL_COMPILER_VCXX_I_)
|
#if SOL_IS_ON(SOL_COMPILER_VCXX)
|
||||||
// MSVC is broken, what a surprise...
|
// MSVC is broken, what a surprise...
|
||||||
#else
|
#else
|
||||||
noexcept(traits_type::is_noexcept)
|
noexcept(traits_type::is_noexcept)
|
||||||
|
|
@ -216,7 +216,7 @@ namespace sol { namespace function_detail {
|
||||||
|
|
||||||
template <bool is_yielding, bool no_trampoline>
|
template <bool is_yielding, bool no_trampoline>
|
||||||
static int call(lua_State* L)
|
static int call(lua_State* L)
|
||||||
#if SOL_IS_ON(SOL_COMPILER_VCXX_I_)
|
#if SOL_IS_ON(SOL_COMPILER_VCXX)
|
||||||
// MSVC is broken, what a surprise...
|
// MSVC is broken, what a surprise...
|
||||||
#else
|
#else
|
||||||
noexcept(traits_type::is_noexcept)
|
noexcept(traits_type::is_noexcept)
|
||||||
|
|
@ -238,7 +238,7 @@ namespace sol { namespace function_detail {
|
||||||
}
|
}
|
||||||
|
|
||||||
int operator()(lua_State* L)
|
int operator()(lua_State* L)
|
||||||
#if SOL_IS_ON(SOL_COMPILER_VCXX_I_)
|
#if SOL_IS_ON(SOL_COMPILER_VCXX)
|
||||||
// MSVC is broken, what a surprise...
|
// MSVC is broken, what a surprise...
|
||||||
#else
|
#else
|
||||||
noexcept(traits_type::is_noexcept)
|
noexcept(traits_type::is_noexcept)
|
||||||
|
|
@ -254,7 +254,7 @@ namespace sol { namespace function_detail {
|
||||||
typedef lua_bind_traits<function_type> traits_type;
|
typedef lua_bind_traits<function_type> traits_type;
|
||||||
|
|
||||||
static int real_call(lua_State* L)
|
static int real_call(lua_State* L)
|
||||||
#if SOL_IS_ON(SOL_COMPILER_VCXX_I_)
|
#if SOL_IS_ON(SOL_COMPILER_VCXX)
|
||||||
// MSVC is broken, what a surprise...
|
// MSVC is broken, what a surprise...
|
||||||
#else
|
#else
|
||||||
noexcept(traits_type::is_noexcept)
|
noexcept(traits_type::is_noexcept)
|
||||||
|
|
@ -268,7 +268,7 @@ namespace sol { namespace function_detail {
|
||||||
|
|
||||||
template <bool is_yielding, bool no_trampoline>
|
template <bool is_yielding, bool no_trampoline>
|
||||||
static int call(lua_State* L)
|
static int call(lua_State* L)
|
||||||
#if SOL_IS_ON(SOL_COMPILER_VCXX_I_)
|
#if SOL_IS_ON(SOL_COMPILER_VCXX)
|
||||||
// MSVC is broken, what a surprise...
|
// MSVC is broken, what a surprise...
|
||||||
#else
|
#else
|
||||||
noexcept(traits_type::is_noexcept)
|
noexcept(traits_type::is_noexcept)
|
||||||
|
|
@ -290,7 +290,7 @@ namespace sol { namespace function_detail {
|
||||||
}
|
}
|
||||||
|
|
||||||
int operator()(lua_State* L)
|
int operator()(lua_State* L)
|
||||||
#if SOL_IS_ON(SOL_COMPILER_VCXX_I_)
|
#if SOL_IS_ON(SOL_COMPILER_VCXX)
|
||||||
// MSVC is broken, what a surprise...
|
// MSVC is broken, what a surprise...
|
||||||
#else
|
#else
|
||||||
noexcept(traits_type::is_noexcept)
|
noexcept(traits_type::is_noexcept)
|
||||||
|
|
@ -320,7 +320,13 @@ namespace sol { namespace function_detail {
|
||||||
}
|
}
|
||||||
|
|
||||||
template <bool is_yielding, bool no_trampoline>
|
template <bool is_yielding, bool no_trampoline>
|
||||||
static int call(lua_State* L) noexcept(std::is_nothrow_copy_assignable_v<T>) {
|
static int call(lua_State* L)
|
||||||
|
#if SOL_IS_ON(SOL_COMPILER_CLANG)
|
||||||
|
// apparent regression in clang 18 - llvm/llvm-project#91362
|
||||||
|
#else
|
||||||
|
noexcept(std::is_nothrow_copy_assignable_v<T>)
|
||||||
|
#endif
|
||||||
|
{
|
||||||
int nr;
|
int nr;
|
||||||
if constexpr (no_trampoline) {
|
if constexpr (no_trampoline) {
|
||||||
nr = real_call(L);
|
nr = real_call(L);
|
||||||
|
|
@ -360,7 +366,13 @@ namespace sol { namespace function_detail {
|
||||||
}
|
}
|
||||||
|
|
||||||
template <bool is_yielding, bool no_trampoline>
|
template <bool is_yielding, bool no_trampoline>
|
||||||
static int call(lua_State* L) noexcept(std::is_nothrow_copy_assignable_v<T>) {
|
static int call(lua_State* L)
|
||||||
|
#if SOL_IS_ON(SOL_COMPILER_CLANG)
|
||||||
|
// apparent regression in clang 18 - llvm/llvm-project#91362
|
||||||
|
#else
|
||||||
|
noexcept(std::is_nothrow_copy_assignable_v<T>)
|
||||||
|
#endif
|
||||||
|
{
|
||||||
int nr;
|
int nr;
|
||||||
if constexpr (no_trampoline) {
|
if constexpr (no_trampoline) {
|
||||||
nr = real_call(L);
|
nr = real_call(L);
|
||||||
|
|
|
||||||
4
extern/sol3/sol/function_types_templated.hpp
vendored
4
extern/sol3/sol/function_types_templated.hpp
vendored
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
// The MIT License (MIT)
|
// The MIT License (MIT)
|
||||||
|
|
||||||
// Copyright (c) 2013-2021 Rapptz, ThePhD and contributors
|
// Copyright (c) 2013-2022 Rapptz, ThePhD and contributors
|
||||||
|
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
// this software and associated documentation files (the "Software"), to deal in
|
// this software and associated documentation files (the "Software"), to deal in
|
||||||
|
|
@ -121,7 +121,7 @@ namespace sol {
|
||||||
typedef meta::unqualified_t<F> Fu;
|
typedef meta::unqualified_t<F> Fu;
|
||||||
typedef std::integral_constant<bool,
|
typedef std::integral_constant<bool,
|
||||||
std::is_same<Fu, lua_CFunction>::value
|
std::is_same<Fu, lua_CFunction>::value
|
||||||
#if SOL_IS_ON(SOL_USE_NOEXCEPT_FUNCTION_TYPE_I_)
|
#if SOL_IS_ON(SOL_USE_NOEXCEPT_FUNCTION_TYPE)
|
||||||
|| std::is_same<Fu, detail::lua_CFunction_noexcept>::value
|
|| std::is_same<Fu, detail::lua_CFunction_noexcept>::value
|
||||||
#endif
|
#endif
|
||||||
>
|
>
|
||||||
|
|
|
||||||
2
extern/sol3/sol/in_place.hpp
vendored
2
extern/sol3/sol/in_place.hpp
vendored
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
// The MIT License (MIT)
|
// The MIT License (MIT)
|
||||||
|
|
||||||
// Copyright (c) 2013-2021 Rapptz, ThePhD and contributors
|
// Copyright (c) 2013-2022 Rapptz, ThePhD and contributors
|
||||||
|
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
// this software and associated documentation files (the "Software"), to deal in
|
// this software and associated documentation files (the "Software"), to deal in
|
||||||
|
|
|
||||||
390
extern/sol3/sol/inheritance.hpp
vendored
390
extern/sol3/sol/inheritance.hpp
vendored
|
|
@ -1,195 +1,195 @@
|
||||||
// sol2
|
// sol2
|
||||||
|
|
||||||
// The MIT License (MIT)
|
// The MIT License (MIT)
|
||||||
|
|
||||||
// Copyright (c) 2013-2021 Rapptz, ThePhD and contributors
|
// Copyright (c) 2013-2022 Rapptz, ThePhD and contributors
|
||||||
|
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
// this software and associated documentation files (the "Software"), to deal in
|
// this software and associated documentation files (the "Software"), to deal in
|
||||||
// the Software without restriction, including without limitation the rights to
|
// the Software without restriction, including without limitation the rights to
|
||||||
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||||
// the Software, and to permit persons to whom the Software is furnished to do so,
|
// the Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
// subject to the following conditions:
|
// subject to the following conditions:
|
||||||
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
// The above copyright notice and this permission notice shall be included in all
|
||||||
// copies or substantial portions of the Software.
|
// copies or substantial portions of the Software.
|
||||||
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
#ifndef SOL_INHERITANCE_HPP
|
#ifndef SOL_INHERITANCE_HPP
|
||||||
#define SOL_INHERITANCE_HPP
|
#define SOL_INHERITANCE_HPP
|
||||||
|
|
||||||
#include <sol/types.hpp>
|
#include <sol/types.hpp>
|
||||||
#include <sol/usertype_traits.hpp>
|
#include <sol/usertype_traits.hpp>
|
||||||
#include <sol/unique_usertype_traits.hpp>
|
#include <sol/unique_usertype_traits.hpp>
|
||||||
|
|
||||||
namespace sol {
|
namespace sol {
|
||||||
template <typename... Args>
|
template <typename... Args>
|
||||||
struct base_list { };
|
struct base_list { };
|
||||||
template <typename... Args>
|
template <typename... Args>
|
||||||
using bases = base_list<Args...>;
|
using bases = base_list<Args...>;
|
||||||
|
|
||||||
typedef bases<> base_classes_tag;
|
typedef bases<> base_classes_tag;
|
||||||
const auto base_classes = base_classes_tag();
|
const auto base_classes = base_classes_tag();
|
||||||
|
|
||||||
template <typename... Args>
|
template <typename... Args>
|
||||||
struct is_to_stringable<base_list<Args...>> : std::false_type { };
|
struct is_to_stringable<base_list<Args...>> : std::false_type { };
|
||||||
|
|
||||||
namespace detail {
|
namespace detail {
|
||||||
|
|
||||||
inline decltype(auto) base_class_check_key() {
|
inline decltype(auto) base_class_check_key() {
|
||||||
static const auto& key = "class_check";
|
static const auto& key = "class_check";
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline decltype(auto) base_class_cast_key() {
|
inline decltype(auto) base_class_cast_key() {
|
||||||
static const auto& key = "class_cast";
|
static const auto& key = "class_cast";
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline decltype(auto) base_class_index_propogation_key() {
|
inline decltype(auto) base_class_index_propogation_key() {
|
||||||
static const auto& key = u8"\xF0\x9F\x8C\xB2.index";
|
static const auto& key = u8"\xF0\x9F\x8C\xB2.index";
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline decltype(auto) base_class_new_index_propogation_key() {
|
inline decltype(auto) base_class_new_index_propogation_key() {
|
||||||
static const auto& key = u8"\xF0\x9F\x8C\xB2.new_index";
|
static const auto& key = u8"\xF0\x9F\x8C\xB2.new_index";
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct inheritance {
|
struct inheritance {
|
||||||
typedef typename base<T>::type bases_t;
|
typedef typename base<T>::type bases_t;
|
||||||
|
|
||||||
static bool type_check_bases(types<>, const string_view&) {
|
static bool type_check_bases(types<>, const string_view&) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Base, typename... Args>
|
template <typename Base, typename... Args>
|
||||||
static bool type_check_bases(types<Base, Args...>, const string_view& ti) {
|
static bool type_check_bases(types<Base, Args...>, const string_view& ti) {
|
||||||
return ti == usertype_traits<Base>::qualified_name() || type_check_bases(types<Args...>(), ti);
|
return ti == usertype_traits<Base>::qualified_name() || type_check_bases(types<Args...>(), ti);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool type_check(const string_view& ti) {
|
static bool type_check(const string_view& ti) {
|
||||||
return ti == usertype_traits<T>::qualified_name() || type_check_bases(bases_t(), ti);
|
return ti == usertype_traits<T>::qualified_name() || type_check_bases(bases_t(), ti);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename... Bases>
|
template <typename... Bases>
|
||||||
static bool type_check_with(const string_view& ti) {
|
static bool type_check_with(const string_view& ti) {
|
||||||
return ti == usertype_traits<T>::qualified_name() || type_check_bases(types<Bases...>(), ti);
|
return ti == usertype_traits<T>::qualified_name() || type_check_bases(types<Bases...>(), ti);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void* type_cast_bases(types<>, T*, const string_view&) {
|
static void* type_cast_bases(types<>, T*, const string_view&) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Base, typename... Args>
|
template <typename Base, typename... Args>
|
||||||
static void* type_cast_bases(types<Base, Args...>, T* data, const string_view& ti) {
|
static void* type_cast_bases(types<Base, Args...>, T* data, const string_view& ti) {
|
||||||
// Make sure to convert to T first, and then dynamic cast to the proper type
|
// Make sure to convert to T first, and then dynamic cast to the proper type
|
||||||
return ti != usertype_traits<Base>::qualified_name() ? type_cast_bases(types<Args...>(), data, ti)
|
return ti != usertype_traits<Base>::qualified_name() ? type_cast_bases(types<Args...>(), data, ti)
|
||||||
: static_cast<void*>(static_cast<Base*>(data));
|
: static_cast<void*>(static_cast<Base*>(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void* type_cast(void* voiddata, const string_view& ti) {
|
static void* type_cast(void* voiddata, const string_view& ti) {
|
||||||
T* data = static_cast<T*>(voiddata);
|
T* data = static_cast<T*>(voiddata);
|
||||||
return static_cast<void*>(ti != usertype_traits<T>::qualified_name() ? type_cast_bases(bases_t(), data, ti) : data);
|
return static_cast<void*>(ti != usertype_traits<T>::qualified_name() ? type_cast_bases(bases_t(), data, ti) : data);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename... Bases>
|
template <typename... Bases>
|
||||||
static void* type_cast_with(void* voiddata, const string_view& ti) {
|
static void* type_cast_with(void* voiddata, const string_view& ti) {
|
||||||
T* data = static_cast<T*>(voiddata);
|
T* data = static_cast<T*>(voiddata);
|
||||||
return static_cast<void*>(ti != usertype_traits<T>::qualified_name() ? type_cast_bases(types<Bases...>(), data, ti) : data);
|
return static_cast<void*>(ti != usertype_traits<T>::qualified_name() ? type_cast_bases(types<Bases...>(), data, ti) : data);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename U>
|
template <typename U>
|
||||||
static bool type_unique_cast_bases(types<>, void*, void*, const string_view&) {
|
static bool type_unique_cast_bases(types<>, void*, void*, const string_view&) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename U, typename Base, typename... Args>
|
template <typename U, typename Base, typename... Args>
|
||||||
static int type_unique_cast_bases(types<Base, Args...>, void* source_data, void* target_data, const string_view& ti) {
|
static int type_unique_cast_bases(types<Base, Args...>, void* source_data, void* target_data, const string_view& ti) {
|
||||||
using uu_traits = unique_usertype_traits<U>;
|
using uu_traits = unique_usertype_traits<U>;
|
||||||
using base_ptr = typename uu_traits::template rebind_actual_type<Base>;
|
using base_ptr = typename uu_traits::template rebind_actual_type<Base>;
|
||||||
string_view base_ti = usertype_traits<Base>::qualified_name();
|
string_view base_ti = usertype_traits<Base>::qualified_name();
|
||||||
if (base_ti == ti) {
|
if (base_ti == ti) {
|
||||||
if (target_data != nullptr) {
|
if (target_data != nullptr) {
|
||||||
U* source = static_cast<U*>(source_data);
|
U* source = static_cast<U*>(source_data);
|
||||||
base_ptr* target = static_cast<base_ptr*>(target_data);
|
base_ptr* target = static_cast<base_ptr*>(target_data);
|
||||||
// perform proper derived -> base conversion
|
// perform proper derived -> base conversion
|
||||||
*target = *source;
|
*target = *source;
|
||||||
}
|
}
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
return type_unique_cast_bases<U>(types<Args...>(), source_data, target_data, ti);
|
return type_unique_cast_bases<U>(types<Args...>(), source_data, target_data, ti);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename U>
|
template <typename U>
|
||||||
static int type_unique_cast(void* source_data, void* target_data, const string_view& ti, const string_view& rebind_ti) {
|
static int type_unique_cast(void* source_data, void* target_data, const string_view& ti, const string_view& rebind_ti) {
|
||||||
if constexpr (is_actual_type_rebindable_for_v<U>) {
|
if constexpr (is_actual_type_rebindable_for_v<U>) {
|
||||||
using rebound_actual_type = unique_usertype_rebind_actual_t<U>;
|
using rebound_actual_type = unique_usertype_rebind_actual_t<U>;
|
||||||
using maybe_bases_or_empty = meta::conditional_t<std::is_void_v<rebound_actual_type>, types<>, bases_t>;
|
using maybe_bases_or_empty = meta::conditional_t<std::is_void_v<rebound_actual_type>, types<>, bases_t>;
|
||||||
string_view this_rebind_ti = usertype_traits<rebound_actual_type>::qualified_name();
|
string_view this_rebind_ti = usertype_traits<rebound_actual_type>::qualified_name();
|
||||||
if (rebind_ti != this_rebind_ti) {
|
if (rebind_ti != this_rebind_ti) {
|
||||||
// this is not even of the same unique type
|
// this is not even of the same unique type
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
string_view this_ti = usertype_traits<T>::qualified_name();
|
string_view this_ti = usertype_traits<T>::qualified_name();
|
||||||
if (ti == this_ti) {
|
if (ti == this_ti) {
|
||||||
// direct match, return 1
|
// direct match, return 1
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return type_unique_cast_bases<U>(maybe_bases_or_empty(), source_data, target_data, ti);
|
return type_unique_cast_bases<U>(maybe_bases_or_empty(), source_data, target_data, ti);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
(void)rebind_ti;
|
(void)rebind_ti;
|
||||||
string_view this_ti = usertype_traits<T>::qualified_name();
|
string_view this_ti = usertype_traits<T>::qualified_name();
|
||||||
if (ti == this_ti) {
|
if (ti == this_ti) {
|
||||||
// direct match, return 1
|
// direct match, return 1
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return type_unique_cast_bases<U>(types<>(), source_data, target_data, ti);
|
return type_unique_cast_bases<U>(types<>(), source_data, target_data, ti);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename U, typename... Bases>
|
template <typename U, typename... Bases>
|
||||||
static int type_unique_cast_with(void* source_data, void* target_data, const string_view& ti, const string_view& rebind_ti) {
|
static int type_unique_cast_with(void* source_data, void* target_data, const string_view& ti, const string_view& rebind_ti) {
|
||||||
using uc_bases_t = types<Bases...>;
|
using uc_bases_t = types<Bases...>;
|
||||||
if constexpr (is_actual_type_rebindable_for_v<U>) {
|
if constexpr (is_actual_type_rebindable_for_v<U>) {
|
||||||
using rebound_actual_type = unique_usertype_rebind_actual_t<U>;
|
using rebound_actual_type = unique_usertype_rebind_actual_t<U>;
|
||||||
using cond_bases_t = meta::conditional_t<std::is_void_v<rebound_actual_type>, types<>, uc_bases_t>;
|
using cond_bases_t = meta::conditional_t<std::is_void_v<rebound_actual_type>, types<>, uc_bases_t>;
|
||||||
string_view this_rebind_ti = usertype_traits<rebound_actual_type>::qualified_name();
|
string_view this_rebind_ti = usertype_traits<rebound_actual_type>::qualified_name();
|
||||||
if (rebind_ti != this_rebind_ti) {
|
if (rebind_ti != this_rebind_ti) {
|
||||||
// this is not even of the same unique type
|
// this is not even of the same unique type
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
string_view this_ti = usertype_traits<T>::qualified_name();
|
string_view this_ti = usertype_traits<T>::qualified_name();
|
||||||
if (ti == this_ti) {
|
if (ti == this_ti) {
|
||||||
// direct match, return 1
|
// direct match, return 1
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return type_unique_cast_bases<U>(cond_bases_t(), source_data, target_data, ti);
|
return type_unique_cast_bases<U>(cond_bases_t(), source_data, target_data, ti);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
(void)rebind_ti;
|
(void)rebind_ti;
|
||||||
string_view this_ti = usertype_traits<T>::qualified_name();
|
string_view this_ti = usertype_traits<T>::qualified_name();
|
||||||
if (ti == this_ti) {
|
if (ti == this_ti) {
|
||||||
// direct match, return 1
|
// direct match, return 1
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return type_unique_cast_bases<U>(types<>(), source_data, target_data, ti);
|
return type_unique_cast_bases<U>(types<>(), source_data, target_data, ti);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
using inheritance_check_function = decltype(&inheritance<void>::type_check);
|
using inheritance_check_function = decltype(&inheritance<void>::type_check);
|
||||||
using inheritance_cast_function = decltype(&inheritance<void>::type_cast);
|
using inheritance_cast_function = decltype(&inheritance<void>::type_cast);
|
||||||
using inheritance_unique_cast_function = decltype(&inheritance<void>::type_unique_cast<void>);
|
using inheritance_unique_cast_function = decltype(&inheritance<void>::type_unique_cast<void>);
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
} // namespace sol
|
} // namespace sol
|
||||||
|
|
||||||
#endif // SOL_INHERITANCE_HPP
|
#endif // SOL_INHERITANCE_HPP
|
||||||
|
|
|
||||||
16
extern/sol3/sol/load_result.hpp
vendored
16
extern/sol3/sol/load_result.hpp
vendored
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
// The MIT License (MIT)
|
// The MIT License (MIT)
|
||||||
|
|
||||||
// Copyright (c) 2013-2021 Rapptz, ThePhD and contributors
|
// Copyright (c) 2013-2022 Rapptz, ThePhD and contributors
|
||||||
|
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
// this software and associated documentation files (the "Software"), to deal in
|
// this software and associated documentation files (the "Software"), to deal in
|
||||||
|
|
@ -39,7 +39,7 @@ namespace sol {
|
||||||
load_status err;
|
load_status err;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
load_result() noexcept = default;
|
load_result() noexcept : load_result(nullptr) {}
|
||||||
load_result(lua_State* Ls, int stackindex = -1, int retnum = 0, int popnum = 0, load_status lerr = load_status::ok) noexcept
|
load_result(lua_State* Ls, int stackindex = -1, int retnum = 0, int popnum = 0, load_status lerr = load_status::ok) noexcept
|
||||||
: L(Ls), index(stackindex), returncount(retnum), popcount(popnum), err(lerr) {
|
: L(Ls), index(stackindex), returncount(retnum), popcount(popnum), err(lerr) {
|
||||||
}
|
}
|
||||||
|
|
@ -95,7 +95,7 @@ namespace sol {
|
||||||
if (valid()) {
|
if (valid()) {
|
||||||
return UT(nullopt);
|
return UT(nullopt);
|
||||||
}
|
}
|
||||||
return error(detail::direct_error, stack::get<std::string>(L, index));
|
return stack::stack_detail::get_error(L, index);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (!valid()) {
|
if (!valid()) {
|
||||||
|
|
@ -106,15 +106,15 @@ namespace sol {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if constexpr (std::is_same_v<T, error>) {
|
if constexpr (std::is_same_v<T, error>) {
|
||||||
#if SOL_IS_ON(SOL_SAFE_PROXIES_I_)
|
#if SOL_IS_ON(SOL_SAFE_PROXIES)
|
||||||
if (valid()) {
|
if (valid()) {
|
||||||
type_panic_c_str(L, index, type_of(L, index), type::none, "expecting an error type (a string, from Lua)");
|
type_panic_c_str(L, index, type_of(L, index), type::none, "expecting an error type (a string, from Lua)");
|
||||||
}
|
}
|
||||||
#endif // Check proxy type's safety
|
#endif // Check proxy type's safety
|
||||||
return error(detail::direct_error, stack::get<std::string>(L, index));
|
return stack::stack_detail::get_error(L, index);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
#if SOL_IS_ON(SOL_SAFE_PROXIES_I_)
|
#if SOL_IS_ON(SOL_SAFE_PROXIES)
|
||||||
if (!valid()) {
|
if (!valid()) {
|
||||||
type_panic_c_str(L, index, type_of(L, index), type::none);
|
type_panic_c_str(L, index, type_of(L, index), type::none);
|
||||||
}
|
}
|
||||||
|
|
@ -142,7 +142,9 @@ namespace sol {
|
||||||
};
|
};
|
||||||
|
|
||||||
~load_result() {
|
~load_result() {
|
||||||
stack::remove(L, index, popcount);
|
if (L != nullptr) {
|
||||||
|
stack::remove(L, index, popcount);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} // namespace sol
|
} // namespace sol
|
||||||
|
|
|
||||||
190
extern/sol3/sol/lua_table.hpp
vendored
190
extern/sol3/sol/lua_table.hpp
vendored
|
|
@ -1,95 +1,95 @@
|
||||||
// sol2
|
// sol2
|
||||||
|
|
||||||
// The MIT License (MIT)
|
// The MIT License (MIT)
|
||||||
|
|
||||||
// Copyright (c) 2013-2021 Rapptz, ThePhD and contributors
|
// Copyright (c) 2013-2022 Rapptz, ThePhD and contributors
|
||||||
|
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
// this software and associated documentation files (the "Software"), to deal in
|
// this software and associated documentation files (the "Software"), to deal in
|
||||||
// the Software without restriction, including without limitation the rights to
|
// the Software without restriction, including without limitation the rights to
|
||||||
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||||
// the Software, and to permit persons to whom the Software is furnished to do so,
|
// the Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
// subject to the following conditions:
|
// subject to the following conditions:
|
||||||
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
// The above copyright notice and this permission notice shall be included in all
|
||||||
// copies or substantial portions of the Software.
|
// copies or substantial portions of the Software.
|
||||||
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
#ifndef SOL_LUA_TABLE_HPP
|
#ifndef SOL_LUA_TABLE_HPP
|
||||||
#define SOL_LUA_TABLE_HPP
|
#define SOL_LUA_TABLE_HPP
|
||||||
|
|
||||||
#include <sol/table_core.hpp>
|
#include <sol/table_core.hpp>
|
||||||
|
|
||||||
namespace sol {
|
namespace sol {
|
||||||
|
|
||||||
template <typename ref_t>
|
template <typename ref_t>
|
||||||
struct basic_lua_table : basic_table_core<false, ref_t> {
|
struct basic_lua_table : basic_table_core<false, ref_t> {
|
||||||
private:
|
private:
|
||||||
using base_t = basic_table_core<false, ref_t>;
|
using base_t = basic_table_core<false, ref_t>;
|
||||||
|
|
||||||
friend class state;
|
friend class state;
|
||||||
friend class state_view;
|
friend class state_view;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
using base_t::lua_state;
|
using base_t::lua_state;
|
||||||
|
|
||||||
basic_lua_table() noexcept = default;
|
basic_lua_table() noexcept = default;
|
||||||
basic_lua_table(const basic_lua_table&) = default;
|
basic_lua_table(const basic_lua_table&) = default;
|
||||||
basic_lua_table(basic_lua_table&&) = default;
|
basic_lua_table(basic_lua_table&&) = default;
|
||||||
basic_lua_table& operator=(const basic_lua_table&) = default;
|
basic_lua_table& operator=(const basic_lua_table&) = default;
|
||||||
basic_lua_table& operator=(basic_lua_table&&) = default;
|
basic_lua_table& operator=(basic_lua_table&&) = default;
|
||||||
basic_lua_table(const stack_reference& r) : basic_lua_table(r.lua_state(), r.stack_index()) {
|
basic_lua_table(const stack_reference& r) : basic_lua_table(r.lua_state(), r.stack_index()) {
|
||||||
}
|
}
|
||||||
basic_lua_table(stack_reference&& r) : basic_lua_table(r.lua_state(), r.stack_index()) {
|
basic_lua_table(stack_reference&& r) : basic_lua_table(r.lua_state(), r.stack_index()) {
|
||||||
}
|
}
|
||||||
template <typename T, meta::enable_any<is_lua_reference<meta::unqualified_t<T>>> = meta::enabler>
|
template <typename T, meta::enable_any<is_lua_reference<meta::unqualified_t<T>>> = meta::enabler>
|
||||||
basic_lua_table(lua_State* L, T&& r) : base_t(L, std::forward<T>(r)) {
|
basic_lua_table(lua_State* L, T&& r) : base_t(L, std::forward<T>(r)) {
|
||||||
#if SOL_IS_ON(SOL_SAFE_REFERENCES_I_)
|
#if SOL_IS_ON(SOL_SAFE_REFERENCES)
|
||||||
auto pp = stack::push_pop(*this);
|
auto pp = stack::push_pop(*this);
|
||||||
constructor_handler handler {};
|
constructor_handler handler {};
|
||||||
stack::check<basic_lua_table>(lua_state(), -1, handler);
|
stack::check<basic_lua_table>(lua_state(), -1, handler);
|
||||||
#endif // Safety
|
#endif // Safety
|
||||||
}
|
}
|
||||||
basic_lua_table(lua_State* L, const new_table& nt) : base_t(L, nt) {
|
basic_lua_table(lua_State* L, const new_table& nt) : base_t(L, nt) {
|
||||||
if (!is_stack_based<meta::unqualified_t<ref_t>>::value) {
|
if (!is_stack_based<meta::unqualified_t<ref_t>>::value) {
|
||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
basic_lua_table(lua_State* L, int index = -1) : base_t(detail::no_safety, L, index) {
|
basic_lua_table(lua_State* L, int index = -1) : base_t(detail::no_safety, L, index) {
|
||||||
#if SOL_IS_ON(SOL_SAFE_REFERENCES_I_)
|
#if SOL_IS_ON(SOL_SAFE_REFERENCES)
|
||||||
constructor_handler handler {};
|
constructor_handler handler {};
|
||||||
stack::check<basic_lua_table>(L, index, handler);
|
stack::check<basic_lua_table>(L, index, handler);
|
||||||
#endif // Safety
|
#endif // Safety
|
||||||
}
|
}
|
||||||
basic_lua_table(lua_State* L, ref_index index) : base_t(detail::no_safety, L, index) {
|
basic_lua_table(lua_State* L, ref_index index) : base_t(detail::no_safety, L, index) {
|
||||||
#if SOL_IS_ON(SOL_SAFE_REFERENCES_I_)
|
#if SOL_IS_ON(SOL_SAFE_REFERENCES)
|
||||||
auto pp = stack::push_pop(*this);
|
auto pp = stack::push_pop(*this);
|
||||||
constructor_handler handler {};
|
constructor_handler handler {};
|
||||||
stack::check<basic_lua_table>(lua_state(), -1, handler);
|
stack::check<basic_lua_table>(lua_state(), -1, handler);
|
||||||
#endif // Safety
|
#endif // Safety
|
||||||
}
|
}
|
||||||
template <typename T,
|
template <typename T,
|
||||||
meta::enable<meta::neg<meta::any_same<meta::unqualified_t<T>, basic_lua_table>>, meta::neg<std::is_same<ref_t, stack_reference>>,
|
meta::enable<meta::neg<meta::any_same<meta::unqualified_t<T>, basic_lua_table>>, meta::neg<std::is_same<ref_t, stack_reference>>,
|
||||||
meta::neg<std::is_same<lua_nil_t, meta::unqualified_t<T>>>, is_lua_reference<meta::unqualified_t<T>>> = meta::enabler>
|
meta::neg<std::is_same<lua_nil_t, meta::unqualified_t<T>>>, is_lua_reference<meta::unqualified_t<T>>> = meta::enabler>
|
||||||
basic_lua_table(T&& r) noexcept : basic_lua_table(detail::no_safety, std::forward<T>(r)) {
|
basic_lua_table(T&& r) noexcept : basic_lua_table(detail::no_safety, std::forward<T>(r)) {
|
||||||
#if SOL_IS_ON(SOL_SAFE_REFERENCES_I_)
|
#if SOL_IS_ON(SOL_SAFE_REFERENCES)
|
||||||
if (!is_table<meta::unqualified_t<T>>::value) {
|
if (!is_table<meta::unqualified_t<T>>::value) {
|
||||||
auto pp = stack::push_pop(*this);
|
auto pp = stack::push_pop(*this);
|
||||||
constructor_handler handler {};
|
constructor_handler handler {};
|
||||||
stack::check<basic_lua_table>(lua_state(), -1, handler);
|
stack::check<basic_lua_table>(lua_state(), -1, handler);
|
||||||
}
|
}
|
||||||
#endif // Safety
|
#endif // Safety
|
||||||
}
|
}
|
||||||
basic_lua_table(lua_nil_t r) noexcept : basic_lua_table(detail::no_safety, r) {
|
basic_lua_table(lua_nil_t r) noexcept : basic_lua_table(detail::no_safety, r) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace sol
|
} // namespace sol
|
||||||
|
|
||||||
#endif // SOL_LUA_TABLE_HPP
|
#endif // SOL_LUA_TABLE_HPP
|
||||||
|
|
|
||||||
324
extern/sol3/sol/lua_value.hpp
vendored
324
extern/sol3/sol/lua_value.hpp
vendored
|
|
@ -1,162 +1,162 @@
|
||||||
// sol2
|
// sol2
|
||||||
|
|
||||||
// The MIT License (MIT)
|
// The MIT License (MIT)
|
||||||
|
|
||||||
// Copyright (c) 2013-2021 Rapptz, ThePhD and contributors
|
// Copyright (c) 2013-2022 Rapptz, ThePhD and contributors
|
||||||
|
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
// this software and associated documentation files (the "Software"), to deal in
|
// this software and associated documentation files (the "Software"), to deal in
|
||||||
// the Software without restriction, including without limitation the rights to
|
// the Software without restriction, including without limitation the rights to
|
||||||
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||||
// the Software, and to permit persons to whom the Software is furnished to do so,
|
// the Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
// subject to the following conditions:
|
// subject to the following conditions:
|
||||||
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
// The above copyright notice and this permission notice shall be included in all
|
||||||
// copies or substantial portions of the Software.
|
// copies or substantial portions of the Software.
|
||||||
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
#ifndef SOL_LUA_VALUE_HPP
|
#ifndef SOL_LUA_VALUE_HPP
|
||||||
#define SOL_LUA_VALUE_HPP
|
#define SOL_LUA_VALUE_HPP
|
||||||
|
|
||||||
#include <sol/stack.hpp>
|
#include <sol/stack.hpp>
|
||||||
#include <sol/reference.hpp>
|
#include <sol/reference.hpp>
|
||||||
#include <sol/make_reference.hpp>
|
#include <sol/make_reference.hpp>
|
||||||
|
|
||||||
namespace sol {
|
namespace sol {
|
||||||
struct lua_value {
|
struct lua_value {
|
||||||
public:
|
public:
|
||||||
struct arr : detail::ebco<std::initializer_list<lua_value>> {
|
struct arr : detail::ebco<std::initializer_list<lua_value>> {
|
||||||
private:
|
private:
|
||||||
using base_t = detail::ebco<std::initializer_list<lua_value>>;
|
using base_t = detail::ebco<std::initializer_list<lua_value>>;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
using base_t::base_t;
|
using base_t::base_t;
|
||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
template <typename T>
|
template <typename T>
|
||||||
using is_reference_or_lua_value_init_list
|
using is_reference_or_lua_value_init_list
|
||||||
= meta::any<meta::is_specialization_of<T, std::initializer_list>, std::is_same<T, reference>, std::is_same<T, arr>>;
|
= meta::any<meta::is_specialization_of<T, std::initializer_list>, std::is_same<T, reference>, std::is_same<T, arr>>;
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
using is_lua_value_single_constructible = meta::any<std::is_same<T, lua_value>, is_reference_or_lua_value_init_list<T>>;
|
using is_lua_value_single_constructible = meta::any<std::is_same<T, lua_value>, is_reference_or_lua_value_init_list<T>>;
|
||||||
|
|
||||||
static lua_State*& thread_local_lua_state() {
|
static lua_State*& thread_local_lua_state() {
|
||||||
#if SOL_IS_ON(SOL_USE_THREAD_LOCAL_I_)
|
#if SOL_IS_ON(SOL_USE_THREAD_LOCAL)
|
||||||
static thread_local lua_State* L = nullptr;
|
static thread_local lua_State* L = nullptr;
|
||||||
#else
|
#else
|
||||||
static lua_State* L = nullptr;
|
static lua_State* L = nullptr;
|
||||||
#endif
|
#endif
|
||||||
return L;
|
return L;
|
||||||
}
|
}
|
||||||
|
|
||||||
reference ref_value;
|
reference ref_value;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static void set_lua_state(lua_State* L) {
|
static void set_lua_state(lua_State* L) {
|
||||||
thread_local_lua_state() = L;
|
thread_local_lua_state() = L;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, meta::disable<is_reference_or_lua_value_init_list<meta::unqualified_t<T>>> = meta::enabler>
|
template <typename T, meta::disable<is_reference_or_lua_value_init_list<meta::unqualified_t<T>>> = meta::enabler>
|
||||||
lua_value(lua_State* L_, T&& value) : lua_value(((set_lua_state(L_)), std::forward<T>(value))) {
|
lua_value(lua_State* L_, T&& value) : lua_value(((set_lua_state(L_)), std::forward<T>(value))) {
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, meta::disable<is_lua_value_single_constructible<meta::unqualified_t<T>>> = meta::enabler>
|
template <typename T, meta::disable<is_lua_value_single_constructible<meta::unqualified_t<T>>> = meta::enabler>
|
||||||
lua_value(T&& value) : ref_value(make_reference(thread_local_lua_state(), std::forward<T>(value))) {
|
lua_value(T&& value) : ref_value(make_reference(thread_local_lua_state(), std::forward<T>(value))) {
|
||||||
}
|
}
|
||||||
|
|
||||||
lua_value(lua_State* L_, std::initializer_list<std::pair<lua_value, lua_value>> il)
|
lua_value(lua_State* L_, std::initializer_list<std::pair<lua_value, lua_value>> il)
|
||||||
: lua_value([&L_, &il]() {
|
: lua_value([&L_, &il]() {
|
||||||
set_lua_state(L_);
|
set_lua_state(L_);
|
||||||
return std::move(il);
|
return std::move(il);
|
||||||
}()) {
|
}()) {
|
||||||
}
|
}
|
||||||
|
|
||||||
lua_value(std::initializer_list<std::pair<lua_value, lua_value>> il) : ref_value(make_reference(thread_local_lua_state(), std::move(il))) {
|
lua_value(std::initializer_list<std::pair<lua_value, lua_value>> il) : ref_value(make_reference(thread_local_lua_state(), std::move(il))) {
|
||||||
}
|
}
|
||||||
|
|
||||||
lua_value(lua_State* L_, arr il)
|
lua_value(lua_State* L_, arr il)
|
||||||
: lua_value([&L_, &il]() {
|
: lua_value([&L_, &il]() {
|
||||||
set_lua_state(L_);
|
set_lua_state(L_);
|
||||||
return std::move(il);
|
return std::move(il);
|
||||||
}()) {
|
}()) {
|
||||||
}
|
}
|
||||||
|
|
||||||
lua_value(arr il) : ref_value(make_reference(thread_local_lua_state(), std::move(il.value()))) {
|
lua_value(arr il) : ref_value(make_reference(thread_local_lua_state(), std::move(il.value()))) {
|
||||||
}
|
}
|
||||||
|
|
||||||
lua_value(lua_State* L_, reference r)
|
lua_value(lua_State* L_, reference r)
|
||||||
: lua_value([&L_, &r]() {
|
: lua_value([&L_, &r]() {
|
||||||
set_lua_state(L_);
|
set_lua_state(L_);
|
||||||
return std::move(r);
|
return std::move(r);
|
||||||
}()) {
|
}()) {
|
||||||
}
|
}
|
||||||
|
|
||||||
lua_value(reference r) : ref_value(std::move(r)) {
|
lua_value(reference r) : ref_value(std::move(r)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
lua_value(const lua_value&) noexcept = default;
|
lua_value(const lua_value&) noexcept = default;
|
||||||
lua_value(lua_value&&) = default;
|
lua_value(lua_value&&) = default;
|
||||||
lua_value& operator=(const lua_value&) = default;
|
lua_value& operator=(const lua_value&) = default;
|
||||||
lua_value& operator=(lua_value&&) = default;
|
lua_value& operator=(lua_value&&) = default;
|
||||||
|
|
||||||
const reference& value() const& {
|
const reference& value() const& {
|
||||||
return ref_value;
|
return ref_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
reference& value() & {
|
reference& value() & {
|
||||||
return ref_value;
|
return ref_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
reference&& value() && {
|
reference&& value() && {
|
||||||
return std::move(ref_value);
|
return std::move(ref_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
decltype(auto) as() const {
|
decltype(auto) as() const {
|
||||||
ref_value.push();
|
ref_value.push();
|
||||||
return stack::pop<T>(ref_value.lua_state());
|
return stack::pop<T>(ref_value.lua_state());
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
bool is() const {
|
bool is() const {
|
||||||
int r = ref_value.registry_index();
|
int r = ref_value.registry_index();
|
||||||
if (r == LUA_REFNIL)
|
if (r == LUA_REFNIL)
|
||||||
return meta::any_same<meta::unqualified_t<T>, lua_nil_t, nullopt_t, std::nullptr_t>::value ? true : false;
|
return meta::any_same<meta::unqualified_t<T>, lua_nil_t, nullopt_t, std::nullptr_t>::value ? true : false;
|
||||||
if (r == LUA_NOREF)
|
if (r == LUA_NOREF)
|
||||||
return false;
|
return false;
|
||||||
auto pp = stack::push_pop(ref_value);
|
auto pp = stack::push_pop(ref_value);
|
||||||
return stack::check<T>(ref_value.lua_state(), -1, &no_panic);
|
return stack::check<T>(ref_value.lua_state(), -1, &no_panic);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
using array_value = typename lua_value::arr;
|
using array_value = typename lua_value::arr;
|
||||||
|
|
||||||
namespace stack {
|
namespace stack {
|
||||||
template <>
|
template <>
|
||||||
struct unqualified_pusher<lua_value> {
|
struct unqualified_pusher<lua_value> {
|
||||||
static int push(lua_State* L, const lua_value& lv) {
|
static int push(lua_State* L, const lua_value& lv) {
|
||||||
return stack::push(L, lv.value());
|
return stack::push(L, lv.value());
|
||||||
}
|
}
|
||||||
|
|
||||||
static int push(lua_State* L, lua_value&& lv) {
|
static int push(lua_State* L, lua_value&& lv) {
|
||||||
return stack::push(L, std::move(lv).value());
|
return stack::push(L, std::move(lv).value());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct unqualified_getter<lua_value> {
|
struct unqualified_getter<lua_value> {
|
||||||
static lua_value get(lua_State* L, int index, record& tracking) {
|
static lua_value get(lua_State* L, int index, record& tracking) {
|
||||||
return lua_value(L, stack::get<reference>(L, index, tracking));
|
return lua_value(L, stack::get<reference>(L, index, tracking));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} // namespace stack
|
} // namespace stack
|
||||||
} // namespace sol
|
} // namespace sol
|
||||||
|
|
||||||
#endif // SOL_LUA_VALUE_HPP
|
#endif // SOL_LUA_VALUE_HPP
|
||||||
|
|
|
||||||
2
extern/sol3/sol/make_reference.hpp
vendored
2
extern/sol3/sol/make_reference.hpp
vendored
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
// The MIT License (MIT)
|
// The MIT License (MIT)
|
||||||
|
|
||||||
// Copyright (c) 2013-2021 Rapptz, ThePhD and contributors
|
// Copyright (c) 2013-2022 Rapptz, ThePhD and contributors
|
||||||
|
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
// this software and associated documentation files (the "Software"), to deal in
|
// this software and associated documentation files (the "Software"), to deal in
|
||||||
|
|
|
||||||
10
extern/sol3/sol/metatable.hpp
vendored
10
extern/sol3/sol/metatable.hpp
vendored
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
// The MIT License (MIT)
|
// The MIT License (MIT)
|
||||||
|
|
||||||
// Copyright (c) 2013-2021 Rapptz, ThePhD and contributors
|
// Copyright (c) 2013-2022 Rapptz, ThePhD and contributors
|
||||||
|
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
// this software and associated documentation files (the "Software"), to deal in
|
// this software and associated documentation files (the "Software"), to deal in
|
||||||
|
|
@ -86,20 +86,20 @@ namespace sol {
|
||||||
}
|
}
|
||||||
template <typename T, meta::enable_any<is_lua_reference<meta::unqualified_t<T>>> = meta::enabler>
|
template <typename T, meta::enable_any<is_lua_reference<meta::unqualified_t<T>>> = meta::enabler>
|
||||||
basic_metatable(lua_State* L, T&& r) : base_t(L, std::forward<T>(r)) {
|
basic_metatable(lua_State* L, T&& r) : base_t(L, std::forward<T>(r)) {
|
||||||
#if SOL_IS_ON(SOL_SAFE_REFERENCES_I_)
|
#if SOL_IS_ON(SOL_SAFE_REFERENCES)
|
||||||
auto pp = stack::push_pop(*this);
|
auto pp = stack::push_pop(*this);
|
||||||
constructor_handler handler {};
|
constructor_handler handler {};
|
||||||
stack::check<basic_metatable>(lua_state(), -1, handler);
|
stack::check<basic_metatable>(lua_state(), -1, handler);
|
||||||
#endif // Safety
|
#endif // Safety
|
||||||
}
|
}
|
||||||
basic_metatable(lua_State* L, int index = -1) : basic_metatable(detail::no_safety, L, index) {
|
basic_metatable(lua_State* L, int index = -1) : basic_metatable(detail::no_safety, L, index) {
|
||||||
#if SOL_IS_ON(SOL_SAFE_REFERENCES_I_)
|
#if SOL_IS_ON(SOL_SAFE_REFERENCES)
|
||||||
constructor_handler handler {};
|
constructor_handler handler {};
|
||||||
stack::check<basic_metatable>(L, index, handler);
|
stack::check<basic_metatable>(L, index, handler);
|
||||||
#endif // Safety
|
#endif // Safety
|
||||||
}
|
}
|
||||||
basic_metatable(lua_State* L, ref_index index) : basic_metatable(detail::no_safety, L, index) {
|
basic_metatable(lua_State* L, ref_index index) : basic_metatable(detail::no_safety, L, index) {
|
||||||
#if SOL_IS_ON(SOL_SAFE_REFERENCES_I_)
|
#if SOL_IS_ON(SOL_SAFE_REFERENCES)
|
||||||
auto pp = stack::push_pop(*this);
|
auto pp = stack::push_pop(*this);
|
||||||
constructor_handler handler {};
|
constructor_handler handler {};
|
||||||
stack::check<basic_metatable>(lua_state(), -1, handler);
|
stack::check<basic_metatable>(lua_state(), -1, handler);
|
||||||
|
|
@ -109,7 +109,7 @@ namespace sol {
|
||||||
meta::enable<meta::neg<meta::any_same<meta::unqualified_t<T>, basic_metatable>>, meta::neg<std::is_same<base_type, stack_reference>>,
|
meta::enable<meta::neg<meta::any_same<meta::unqualified_t<T>, basic_metatable>>, meta::neg<std::is_same<base_type, stack_reference>>,
|
||||||
meta::neg<std::is_same<lua_nil_t, meta::unqualified_t<T>>>, is_lua_reference<meta::unqualified_t<T>>> = meta::enabler>
|
meta::neg<std::is_same<lua_nil_t, meta::unqualified_t<T>>>, is_lua_reference<meta::unqualified_t<T>>> = meta::enabler>
|
||||||
basic_metatable(T&& r) noexcept : basic_metatable(detail::no_safety, std::forward<T>(r)) {
|
basic_metatable(T&& r) noexcept : basic_metatable(detail::no_safety, std::forward<T>(r)) {
|
||||||
#if SOL_IS_ON(SOL_SAFE_REFERENCES_I_)
|
#if SOL_IS_ON(SOL_SAFE_REFERENCES)
|
||||||
if (!is_table<meta::unqualified_t<T>>::value) {
|
if (!is_table<meta::unqualified_t<T>>::value) {
|
||||||
auto pp = stack::push_pop(*this);
|
auto pp = stack::push_pop(*this);
|
||||||
constructor_handler handler {};
|
constructor_handler handler {};
|
||||||
|
|
|
||||||
2
extern/sol3/sol/object.hpp
vendored
2
extern/sol3/sol/object.hpp
vendored
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
// The MIT License (MIT)
|
// The MIT License (MIT)
|
||||||
|
|
||||||
// Copyright (c) 2013-2021 Rapptz, ThePhD and contributors
|
// Copyright (c) 2013-2022 Rapptz, ThePhD and contributors
|
||||||
|
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
// this software and associated documentation files (the "Software"), to deal in
|
// this software and associated documentation files (the "Software"), to deal in
|
||||||
|
|
|
||||||
2
extern/sol3/sol/object_base.hpp
vendored
2
extern/sol3/sol/object_base.hpp
vendored
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
// The MIT License (MIT)
|
// The MIT License (MIT)
|
||||||
|
|
||||||
// Copyright (c) 2013-2021 Rapptz, ThePhD and contributors
|
// Copyright (c) 2013-2022 Rapptz, ThePhD and contributors
|
||||||
|
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
// this software and associated documentation files (the "Software"), to deal in
|
// this software and associated documentation files (the "Software"), to deal in
|
||||||
|
|
|
||||||
12
extern/sol3/sol/optional.hpp
vendored
12
extern/sol3/sol/optional.hpp
vendored
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
// The MIT License (MIT)
|
// The MIT License (MIT)
|
||||||
|
|
||||||
// Copyright (c) 2013-2021 Rapptz, ThePhD and contributors
|
// Copyright (c) 2013-2022 Rapptz, ThePhD and contributors
|
||||||
|
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
// this software and associated documentation files (the "Software"), to deal in
|
// this software and associated documentation files (the "Software"), to deal in
|
||||||
|
|
@ -27,7 +27,7 @@
|
||||||
#include <sol/forward.hpp>
|
#include <sol/forward.hpp>
|
||||||
#include <sol/in_place.hpp>
|
#include <sol/in_place.hpp>
|
||||||
#include <sol/traits.hpp>
|
#include <sol/traits.hpp>
|
||||||
#if SOL_IS_ON(SOL_USE_BOOST_I_)
|
#if SOL_IS_ON(SOL_USE_BOOST)
|
||||||
#include <boost/optional.hpp>
|
#include <boost/optional.hpp>
|
||||||
#else
|
#else
|
||||||
#include <sol/optional_implementation.hpp>
|
#include <sol/optional_implementation.hpp>
|
||||||
|
|
@ -38,7 +38,7 @@
|
||||||
|
|
||||||
namespace sol {
|
namespace sol {
|
||||||
|
|
||||||
#if SOL_IS_ON(SOL_USE_BOOST_I_)
|
#if SOL_IS_ON(SOL_USE_BOOST)
|
||||||
template <typename T>
|
template <typename T>
|
||||||
using optional = boost::optional<T>;
|
using optional = boost::optional<T>;
|
||||||
using nullopt_t = boost::none_t;
|
using nullopt_t = boost::none_t;
|
||||||
|
|
@ -59,14 +59,14 @@ namespace sol {
|
||||||
inline static constexpr std::nullopt_t value = std::nullopt;
|
inline static constexpr std::nullopt_t value = std::nullopt;
|
||||||
};
|
};
|
||||||
|
|
||||||
#if SOL_IS_ON(SOL_USE_BOOST_I_)
|
#if SOL_IS_ON(SOL_USE_BOOST)
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct associated_nullopt<boost::optional<T>> {
|
struct associated_nullopt<boost::optional<T>> {
|
||||||
inline static SOL_BOOST_NONE_CONSTEXPR_I_ boost::none_t value = boost::none;
|
inline static SOL_BOOST_NONE_CONSTEXPR_I_ boost::none_t value = boost::none;
|
||||||
};
|
};
|
||||||
#endif // Boost nullopt
|
#endif // Boost nullopt
|
||||||
|
|
||||||
#if SOL_IS_ON(SOL_USE_BOOST_I_)
|
#if SOL_IS_ON(SOL_USE_BOOST)
|
||||||
template <typename T>
|
template <typename T>
|
||||||
inline SOL_BOOST_NONE_CONSTEXPR_I_ auto associated_nullopt_v = associated_nullopt<T>::value;
|
inline SOL_BOOST_NONE_CONSTEXPR_I_ auto associated_nullopt_v = associated_nullopt<T>::value;
|
||||||
#else
|
#else
|
||||||
|
|
@ -76,7 +76,7 @@ namespace sol {
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
} // namespace sol
|
} // namespace sol
|
||||||
|
|
||||||
#if SOL_IS_ON(SOL_USE_BOOST_I_)
|
#if SOL_IS_ON(SOL_USE_BOOST)
|
||||||
#undef SOL_BOOST_NONE_CONSTEXPR_I_
|
#undef SOL_BOOST_NONE_CONSTEXPR_I_
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
21
extern/sol3/sol/optional_implementation.hpp
vendored
21
extern/sol3/sol/optional_implementation.hpp
vendored
|
|
@ -1,6 +1,6 @@
|
||||||
// The MIT License (MIT)
|
// The MIT License (MIT)
|
||||||
|
|
||||||
// Copyright (c) 2013-2021 Rapptz, ThePhD and contributors
|
// Copyright (c) 2013-2022 Rapptz, ThePhD and contributors
|
||||||
|
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
// this software and associated documentation files (the "Software"), to deal in
|
// this software and associated documentation files (the "Software"), to deal in
|
||||||
|
|
@ -1375,7 +1375,7 @@ namespace sol {
|
||||||
SOL_TL_OPTIONAL_11_CONSTEXPR T& value() & {
|
SOL_TL_OPTIONAL_11_CONSTEXPR T& value() & {
|
||||||
if (has_value())
|
if (has_value())
|
||||||
return this->m_value;
|
return this->m_value;
|
||||||
#if SOL_IS_OFF(SOL_EXCEPTIONS_I_)
|
#if SOL_IS_OFF(SOL_EXCEPTIONS)
|
||||||
std::abort();
|
std::abort();
|
||||||
#else
|
#else
|
||||||
throw bad_optional_access();
|
throw bad_optional_access();
|
||||||
|
|
@ -1386,7 +1386,7 @@ namespace sol {
|
||||||
SOL_TL_OPTIONAL_11_CONSTEXPR const T& value() const& {
|
SOL_TL_OPTIONAL_11_CONSTEXPR const T& value() const& {
|
||||||
if (has_value())
|
if (has_value())
|
||||||
return this->m_value;
|
return this->m_value;
|
||||||
#if SOL_IS_OFF(SOL_EXCEPTIONS_I_)
|
#if SOL_IS_OFF(SOL_EXCEPTIONS)
|
||||||
std::abort();
|
std::abort();
|
||||||
#else
|
#else
|
||||||
throw bad_optional_access();
|
throw bad_optional_access();
|
||||||
|
|
@ -1396,7 +1396,7 @@ namespace sol {
|
||||||
SOL_TL_OPTIONAL_11_CONSTEXPR T&& value() && {
|
SOL_TL_OPTIONAL_11_CONSTEXPR T&& value() && {
|
||||||
if (has_value())
|
if (has_value())
|
||||||
return std::move(this->m_value);
|
return std::move(this->m_value);
|
||||||
#if SOL_IS_OFF(SOL_EXCEPTIONS_I_)
|
#if SOL_IS_OFF(SOL_EXCEPTIONS)
|
||||||
std::abort();
|
std::abort();
|
||||||
#else
|
#else
|
||||||
throw bad_optional_access();
|
throw bad_optional_access();
|
||||||
|
|
@ -1408,7 +1408,7 @@ namespace sol {
|
||||||
SOL_TL_OPTIONAL_11_CONSTEXPR const T&& value() const&& {
|
SOL_TL_OPTIONAL_11_CONSTEXPR const T&& value() const&& {
|
||||||
if (has_value())
|
if (has_value())
|
||||||
return std::move(this->m_value);
|
return std::move(this->m_value);
|
||||||
#if SOL_IS_OFF(SOL_EXCEPTIONS_I_)
|
#if SOL_IS_OFF(SOL_EXCEPTIONS)
|
||||||
std::abort();
|
std::abort();
|
||||||
#else
|
#else
|
||||||
throw bad_optional_access();
|
throw bad_optional_access();
|
||||||
|
|
@ -2186,12 +2186,9 @@ namespace sol {
|
||||||
/// one.
|
/// one.
|
||||||
///
|
///
|
||||||
/// \group emplace
|
/// \group emplace
|
||||||
template <class... Args>
|
T& emplace(T& arg) noexcept {
|
||||||
T& emplace(Args&&... args) noexcept {
|
|
||||||
static_assert(std::is_constructible<T, Args&&...>::value, "T must be constructible with Args");
|
|
||||||
|
|
||||||
*this = nullopt;
|
*this = nullopt;
|
||||||
new (static_cast<void*>(this)) optional(std::in_place, std::forward<Args>(args)...);
|
m_value = &arg;
|
||||||
return **this;
|
return **this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2251,7 +2248,7 @@ namespace sol {
|
||||||
SOL_TL_OPTIONAL_11_CONSTEXPR T& value() {
|
SOL_TL_OPTIONAL_11_CONSTEXPR T& value() {
|
||||||
if (has_value())
|
if (has_value())
|
||||||
return *m_value;
|
return *m_value;
|
||||||
#if SOL_IS_OFF(SOL_EXCEPTIONS_I_)
|
#if SOL_IS_OFF(SOL_EXCEPTIONS)
|
||||||
std::abort();
|
std::abort();
|
||||||
#else
|
#else
|
||||||
throw bad_optional_access();
|
throw bad_optional_access();
|
||||||
|
|
@ -2262,7 +2259,7 @@ namespace sol {
|
||||||
SOL_TL_OPTIONAL_11_CONSTEXPR const T& value() const {
|
SOL_TL_OPTIONAL_11_CONSTEXPR const T& value() const {
|
||||||
if (has_value())
|
if (has_value())
|
||||||
return *m_value;
|
return *m_value;
|
||||||
#if SOL_IS_OFF(SOL_EXCEPTIONS_I_)
|
#if SOL_IS_OFF(SOL_EXCEPTIONS)
|
||||||
std::abort();
|
std::abort();
|
||||||
#else
|
#else
|
||||||
throw bad_optional_access();
|
throw bad_optional_access();
|
||||||
|
|
|
||||||
4
extern/sol3/sol/overload.hpp
vendored
4
extern/sol3/sol/overload.hpp
vendored
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
// The MIT License (MIT)
|
// The MIT License (MIT)
|
||||||
|
|
||||||
// Copyright (c) 2013-2021 Rapptz, ThePhD and contributors
|
// Copyright (c) 2013-2022 Rapptz, ThePhD and contributors
|
||||||
|
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
// this software and associated documentation files (the "Software"), to deal in
|
// this software and associated documentation files (the "Software"), to deal in
|
||||||
|
|
@ -46,4 +46,4 @@ namespace sol {
|
||||||
}
|
}
|
||||||
} // namespace sol
|
} // namespace sol
|
||||||
|
|
||||||
#endif // SOL_OVERLOAD_HPP
|
#endif // SOL_OVERLOAD_HPP
|
||||||
|
|
|
||||||
524
extern/sol3/sol/packaged_coroutine.hpp
vendored
524
extern/sol3/sol/packaged_coroutine.hpp
vendored
|
|
@ -1,262 +1,262 @@
|
||||||
// sol2
|
// sol2
|
||||||
|
|
||||||
// The MIT License (MIT)
|
// The MIT License (MIT)
|
||||||
|
|
||||||
// Copyright (c) 2013-2021 Rapptz, ThePhD and contributors
|
// Copyright (c) 2013-2022 Rapptz, ThePhD and contributors
|
||||||
|
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
// this software and associated documentation files (the "Software"), to deal in
|
// this software and associated documentation files (the "Software"), to deal in
|
||||||
// the Software without restriction, including without limitation the rights to
|
// the Software without restriction, including without limitation the rights to
|
||||||
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||||
// the Software, and to permit persons to whom the Software is furnished to do so,
|
// the Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
// subject to the following conditions:
|
// subject to the following conditions:
|
||||||
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
// The above copyright notice and this permission notice shall be included in all
|
||||||
// copies or substantial portions of the Software.
|
// copies or substantial portions of the Software.
|
||||||
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
#ifndef SOL_PACKAGED_COROUTINE_HPP
|
#ifndef SOL_PACKAGED_COROUTINE_HPP
|
||||||
#define SOL_PACKAGED_COROUTINE_HPP
|
#define SOL_PACKAGED_COROUTINE_HPP
|
||||||
|
|
||||||
#include <sol/reference.hpp>
|
#include <sol/reference.hpp>
|
||||||
#include <sol/object.hpp>
|
#include <sol/object.hpp>
|
||||||
#include <sol/stack.hpp>
|
#include <sol/stack.hpp>
|
||||||
#include <sol/function_result.hpp>
|
#include <sol/function_result.hpp>
|
||||||
#include <sol/thread.hpp>
|
#include <sol/thread.hpp>
|
||||||
#include <sol/protected_handler.hpp>
|
#include <sol/protected_handler.hpp>
|
||||||
#include <sol/coroutine.hpp>
|
#include <sol/coroutine.hpp>
|
||||||
|
|
||||||
namespace sol {
|
namespace sol {
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
|
|
||||||
class packaged_coroutine {
|
class packaged_coroutine {
|
||||||
private:
|
private:
|
||||||
lua_State* m_L;
|
lua_State* m_L;
|
||||||
sol::stateless_reference m_coroutine_reference;
|
sol::stateless_reference m_coroutine_reference;
|
||||||
sol::stateless_reference m_error_handler;
|
sol::stateless_reference m_error_handler;
|
||||||
sol::thread m_thread_reference;
|
sol::thread m_thread_reference;
|
||||||
|
|
||||||
void luacall(std::ptrdiff_t argcount, std::ptrdiff_t) {
|
void luacall(std::ptrdiff_t argcount, std::ptrdiff_t) {
|
||||||
#if SOL_LUA_VERSION_I_ >= 504
|
#if SOL_LUA_VERSION_I_ >= 504
|
||||||
int nresults;
|
int nresults;
|
||||||
stats = static_cast<call_status>(lua_resume(lua_state(), nullptr, static_cast<int>(argcount), &nresults));
|
stats = static_cast<call_status>(lua_resume(lua_state(), nullptr, static_cast<int>(argcount), &nresults));
|
||||||
#else
|
#else
|
||||||
stats = static_cast<call_status>(lua_resume(lua_state(), nullptr, static_cast<int>(argcount)));
|
stats = static_cast<call_status>(lua_resume(lua_state(), nullptr, static_cast<int>(argcount)));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
template <std::size_t... I, typename... Ret>
|
template <std::size_t... I, typename... Ret>
|
||||||
auto invoke(types<Ret...>, std::index_sequence<I...>, std::ptrdiff_t n) {
|
auto invoke(types<Ret...>, std::index_sequence<I...>, std::ptrdiff_t n) {
|
||||||
luacall(n, sizeof...(Ret));
|
luacall(n, sizeof...(Ret));
|
||||||
return stack::pop<std::tuple<Ret...>>(lua_state());
|
return stack::pop<std::tuple<Ret...>>(lua_state());
|
||||||
}
|
}
|
||||||
|
|
||||||
template <std::size_t I, typename Ret>
|
template <std::size_t I, typename Ret>
|
||||||
Ret invoke(types<Ret>, std::index_sequence<I>, std::ptrdiff_t n) {
|
Ret invoke(types<Ret>, std::index_sequence<I>, std::ptrdiff_t n) {
|
||||||
luacall(n, 1);
|
luacall(n, 1);
|
||||||
return stack::pop<Ret>(lua_state());
|
return stack::pop<Ret>(lua_state());
|
||||||
}
|
}
|
||||||
|
|
||||||
template <std::size_t I>
|
template <std::size_t I>
|
||||||
void invoke(types<void>, std::index_sequence<I>, std::ptrdiff_t n) {
|
void invoke(types<void>, std::index_sequence<I>, std::ptrdiff_t n) {
|
||||||
luacall(n, 0);
|
luacall(n, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected_function_result invoke(types<>, std::index_sequence<>, std::ptrdiff_t n) {
|
protected_function_result invoke(types<>, std::index_sequence<>, std::ptrdiff_t n) {
|
||||||
int firstreturn = 1;
|
int firstreturn = 1;
|
||||||
luacall(n, LUA_MULTRET);
|
luacall(n, LUA_MULTRET);
|
||||||
int poststacksize = lua_gettop(this->lua_state());
|
int poststacksize = lua_gettop(this->lua_state());
|
||||||
int returncount = poststacksize - (firstreturn - 1);
|
int returncount = poststacksize - (firstreturn - 1);
|
||||||
if (error()) {
|
if (error()) {
|
||||||
if (m_error_handler.valid()) {
|
if (m_error_handler.valid()) {
|
||||||
string_view err = stack::get<string_view>(this->lua_state(), poststacksize);
|
string_view err = stack::get<string_view>(this->lua_state(), poststacksize);
|
||||||
m_error_handler.push();
|
m_error_handler.push();
|
||||||
stack::push(this->lua_state(), err);
|
stack::push(this->lua_state(), err);
|
||||||
lua_call(lua_state(), 1, 1);
|
lua_call(lua_state(), 1, 1);
|
||||||
}
|
}
|
||||||
return protected_function_result(this->lua_state(), lua_absindex(this->lua_state(), -1), 1, returncount, status());
|
return protected_function_result(this->lua_state(), lua_absindex(this->lua_state(), -1), 1, returncount, status());
|
||||||
}
|
}
|
||||||
return protected_function_result(this->lua_state(), firstreturn, returncount, returncount, status());
|
return protected_function_result(this->lua_state(), firstreturn, returncount, returncount, status());
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
using base_t::lua_state;
|
using base_t::lua_state;
|
||||||
|
|
||||||
basic_packaged_coroutine() = default;
|
basic_packaged_coroutine() = default;
|
||||||
template <typename T,
|
template <typename T,
|
||||||
meta::enable<meta::neg<std::is_same<meta::unqualified_t<T>, basic_packaged_coroutine>>,
|
meta::enable<meta::neg<std::is_same<meta::unqualified_t<T>, basic_packaged_coroutine>>,
|
||||||
meta::neg<std::is_base_of<proxy_base_tag, meta::unqualified_t<T>>>, meta::neg<std::is_same<base_t, stack_reference>>,
|
meta::neg<std::is_base_of<proxy_base_tag, meta::unqualified_t<T>>>, meta::neg<std::is_same<base_t, stack_reference>>,
|
||||||
meta::neg<std::is_same<lua_nil_t, meta::unqualified_t<T>>>, is_lua_reference<meta::unqualified_t<T>>> = meta::enabler>
|
meta::neg<std::is_same<lua_nil_t, meta::unqualified_t<T>>>, is_lua_reference<meta::unqualified_t<T>>> = meta::enabler>
|
||||||
basic_packaged_coroutine(T&& r) noexcept
|
basic_packaged_coroutine(T&& r) noexcept
|
||||||
: base_t(std::forward<T>(r)), m_error_handler(detail::get_default_handler<reference, is_main_threaded<base_t>::value>(r.lua_state())) {
|
: base_t(std::forward<T>(r)), m_error_handler(detail::get_default_handler<reference, is_main_threaded<base_t>::value>(r.lua_state())) {
|
||||||
#if SOL_IS_ON(SOL_SAFE_REFERENCES_I_)
|
#if SOL_IS_ON(SOL_SAFE_REFERENCES)
|
||||||
if (!is_function<meta::unqualified_t<T>>::value) {
|
if (!is_function<meta::unqualified_t<T>>::value) {
|
||||||
auto pp = stack::push_pop(*this);
|
auto pp = stack::push_pop(*this);
|
||||||
constructor_handler handler {};
|
constructor_handler handler {};
|
||||||
stack::check<basic_packaged_coroutine>(lua_state(), -1, handler);
|
stack::check<basic_packaged_coroutine>(lua_state(), -1, handler);
|
||||||
}
|
}
|
||||||
#endif // Safety
|
#endif // Safety
|
||||||
}
|
}
|
||||||
|
|
||||||
basic_packaged_coroutine(const basic_packaged_coroutine& other) = default;
|
basic_packaged_coroutine(const basic_packaged_coroutine& other) = default;
|
||||||
basic_packaged_coroutine& operator=(const basic_packaged_coroutine&) = default;
|
basic_packaged_coroutine& operator=(const basic_packaged_coroutine&) = default;
|
||||||
|
|
||||||
basic_packaged_coroutine(basic_packaged_coroutine&& other) noexcept
|
basic_packaged_coroutine(basic_packaged_coroutine&& other) noexcept
|
||||||
: base_t(std::move(other)), m_error_handler(this->lua_state(), std::move(other.m_error_handler)) {
|
: base_t(std::move(other)), m_error_handler(this->lua_state(), std::move(other.m_error_handler)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
basic_packaged_coroutine& operator=(basic_packaged_coroutine&& other) noexcept {
|
basic_packaged_coroutine& operator=(basic_packaged_coroutine&& other) noexcept {
|
||||||
base_t::operator=(std::move(other));
|
base_t::operator=(std::move(other));
|
||||||
// must change the state, since it could change on the coroutine type
|
// must change the state, since it could change on the coroutine type
|
||||||
m_error_handler.abandon();
|
m_error_handler.abandon();
|
||||||
m_error_handler = handler_t(this->lua_state(), std::move(other.m_error_handler));
|
m_error_handler = handler_t(this->lua_state(), std::move(other.m_error_handler));
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
basic_packaged_coroutine(const basic_function<base_t>& b) noexcept
|
basic_packaged_coroutine(const basic_function<base_t>& b) noexcept
|
||||||
: basic_packaged_coroutine(b, detail::get_default_handler<reference, is_main_threaded_v<base_t>>(b.lua_state())) {
|
: basic_packaged_coroutine(b, detail::get_default_handler<reference, is_main_threaded_v<base_t>>(b.lua_state())) {
|
||||||
}
|
}
|
||||||
basic_packaged_coroutine(basic_function<base_t>&& b) noexcept
|
basic_packaged_coroutine(basic_function<base_t>&& b) noexcept
|
||||||
: basic_packaged_coroutine(std::move(b), detail::get_default_handler<reference, is_main_threaded_v<base_t>>(b.lua_state())) {
|
: basic_packaged_coroutine(std::move(b), detail::get_default_handler<reference, is_main_threaded_v<base_t>>(b.lua_state())) {
|
||||||
}
|
}
|
||||||
basic_packaged_coroutine(const basic_function<base_t>& b, handler_t eh) noexcept : base_t(b), m_error_handler(std::move(eh)) {
|
basic_packaged_coroutine(const basic_function<base_t>& b, handler_t eh) noexcept : base_t(b), m_error_handler(std::move(eh)) {
|
||||||
}
|
}
|
||||||
basic_packaged_coroutine(basic_function<base_t>&& b, handler_t eh) noexcept : base_t(std::move(b)), m_error_handler(std::move(eh)) {
|
basic_packaged_coroutine(basic_function<base_t>&& b, handler_t eh) noexcept : base_t(std::move(b)), m_error_handler(std::move(eh)) {
|
||||||
}
|
}
|
||||||
basic_packaged_coroutine(const stack_reference& r) noexcept
|
basic_packaged_coroutine(const stack_reference& r) noexcept
|
||||||
: basic_packaged_coroutine(r.lua_state(), r.stack_index(), detail::get_default_handler<reference, is_main_threaded<base_t>::value>(r.lua_state())) {
|
: basic_packaged_coroutine(r.lua_state(), r.stack_index(), detail::get_default_handler<reference, is_main_threaded<base_t>::value>(r.lua_state())) {
|
||||||
}
|
}
|
||||||
basic_packaged_coroutine(stack_reference&& r) noexcept
|
basic_packaged_coroutine(stack_reference&& r) noexcept
|
||||||
: basic_packaged_coroutine(r.lua_state(), r.stack_index(), detail::get_default_handler<reference, is_main_threaded<base_t>::value>(r.lua_state())) {
|
: basic_packaged_coroutine(r.lua_state(), r.stack_index(), detail::get_default_handler<reference, is_main_threaded<base_t>::value>(r.lua_state())) {
|
||||||
}
|
}
|
||||||
basic_packaged_coroutine(const stack_reference& r, handler_t eh) noexcept : basic_packaged_coroutine(r.lua_state(), r.stack_index(), std::move(eh)) {
|
basic_packaged_coroutine(const stack_reference& r, handler_t eh) noexcept : basic_packaged_coroutine(r.lua_state(), r.stack_index(), std::move(eh)) {
|
||||||
}
|
}
|
||||||
basic_packaged_coroutine(stack_reference&& r, handler_t eh) noexcept : basic_packaged_coroutine(r.lua_state(), r.stack_index(), std::move(eh)) {
|
basic_packaged_coroutine(stack_reference&& r, handler_t eh) noexcept : basic_packaged_coroutine(r.lua_state(), r.stack_index(), std::move(eh)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Super>
|
template <typename Super>
|
||||||
basic_packaged_coroutine(const proxy_base<Super>& p)
|
basic_packaged_coroutine(const proxy_base<Super>& p)
|
||||||
: basic_packaged_coroutine(p, detail::get_default_handler<reference, is_main_threaded<base_t>::value>(p.lua_state())) {
|
: basic_packaged_coroutine(p, detail::get_default_handler<reference, is_main_threaded<base_t>::value>(p.lua_state())) {
|
||||||
}
|
}
|
||||||
template <typename Super>
|
template <typename Super>
|
||||||
basic_packaged_coroutine(proxy_base<Super>&& p)
|
basic_packaged_coroutine(proxy_base<Super>&& p)
|
||||||
: basic_packaged_coroutine(std::move(p), detail::get_default_handler<reference, is_main_threaded<base_t>::value>(p.lua_state())) {
|
: basic_packaged_coroutine(std::move(p), detail::get_default_handler<reference, is_main_threaded<base_t>::value>(p.lua_state())) {
|
||||||
}
|
}
|
||||||
template <typename Proxy, typename HandlerReference,
|
template <typename Proxy, typename HandlerReference,
|
||||||
meta::enable<std::is_base_of<proxy_base_tag, meta::unqualified_t<Proxy>>, meta::neg<is_lua_index<meta::unqualified_t<HandlerReference>>>> = meta::enabler>
|
meta::enable<std::is_base_of<proxy_base_tag, meta::unqualified_t<Proxy>>, meta::neg<is_lua_index<meta::unqualified_t<HandlerReference>>>> = meta::enabler>
|
||||||
basic_packaged_coroutine(Proxy&& p, HandlerReference&& eh) : basic_packaged_coroutine(detail::force_cast<base_t>(p), std::forward<HandlerReference>(eh)) {
|
basic_packaged_coroutine(Proxy&& p, HandlerReference&& eh) : basic_packaged_coroutine(detail::force_cast<base_t>(p), std::forward<HandlerReference>(eh)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, meta::enable<is_lua_reference<meta::unqualified_t<T>>> = meta::enabler>
|
template <typename T, meta::enable<is_lua_reference<meta::unqualified_t<T>>> = meta::enabler>
|
||||||
basic_packaged_coroutine(lua_State* L, T&& r) noexcept
|
basic_packaged_coroutine(lua_State* L, T&& r) noexcept
|
||||||
: basic_packaged_coroutine(L, std::forward<T>(r), detail::get_default_handler<reference, is_main_threaded<base_t>::value>(L)) {
|
: basic_packaged_coroutine(L, std::forward<T>(r), detail::get_default_handler<reference, is_main_threaded<base_t>::value>(L)) {
|
||||||
}
|
}
|
||||||
template <typename T, meta::enable<is_lua_reference<meta::unqualified_t<T>>> = meta::enabler>
|
template <typename T, meta::enable<is_lua_reference<meta::unqualified_t<T>>> = meta::enabler>
|
||||||
basic_packaged_coroutine(lua_State* L, T&& r, handler_t eh) : base_t(L, std::forward<T>(r)), m_error_handler(std::move(eh)) {
|
basic_packaged_coroutine(lua_State* L, T&& r, handler_t eh) : base_t(L, std::forward<T>(r)), m_error_handler(std::move(eh)) {
|
||||||
#if SOL_IS_ON(SOL_SAFE_REFERENCES_I_)
|
#if SOL_IS_ON(SOL_SAFE_REFERENCES)
|
||||||
auto pp = stack::push_pop(*this);
|
auto pp = stack::push_pop(*this);
|
||||||
constructor_handler handler {};
|
constructor_handler handler {};
|
||||||
stack::check<basic_packaged_coroutine>(lua_state(), -1, handler);
|
stack::check<basic_packaged_coroutine>(lua_state(), -1, handler);
|
||||||
#endif // Safety
|
#endif // Safety
|
||||||
}
|
}
|
||||||
|
|
||||||
basic_packaged_coroutine(lua_nil_t n) : base_t(n), m_error_handler(n) {
|
basic_packaged_coroutine(lua_nil_t n) : base_t(n), m_error_handler(n) {
|
||||||
}
|
}
|
||||||
|
|
||||||
basic_packaged_coroutine(lua_State* L, int index = -1)
|
basic_packaged_coroutine(lua_State* L, int index = -1)
|
||||||
: basic_packaged_coroutine(L, index, detail::get_default_handler<reference, is_main_threaded<base_t>::value>(L)) {
|
: basic_packaged_coroutine(L, index, detail::get_default_handler<reference, is_main_threaded<base_t>::value>(L)) {
|
||||||
}
|
}
|
||||||
basic_packaged_coroutine(lua_State* L, int index, handler_t eh) : base_t(L, index), m_error_handler(std::move(eh)) {
|
basic_packaged_coroutine(lua_State* L, int index, handler_t eh) : base_t(L, index), m_error_handler(std::move(eh)) {
|
||||||
#ifdef SOL_SAFE_REFERENCES
|
#ifdef SOL_SAFE_REFERENCES
|
||||||
constructor_handler handler {};
|
constructor_handler handler {};
|
||||||
stack::check<basic_packaged_coroutine>(L, index, handler);
|
stack::check<basic_packaged_coroutine>(L, index, handler);
|
||||||
#endif // Safety
|
#endif // Safety
|
||||||
}
|
}
|
||||||
basic_packaged_coroutine(lua_State* L, absolute_index index)
|
basic_packaged_coroutine(lua_State* L, absolute_index index)
|
||||||
: basic_packaged_coroutine(L, index, detail::get_default_handler<reference, is_main_threaded<base_t>::value>(L)) {
|
: basic_packaged_coroutine(L, index, detail::get_default_handler<reference, is_main_threaded<base_t>::value>(L)) {
|
||||||
}
|
}
|
||||||
basic_packaged_coroutine(lua_State* L, absolute_index index, handler_t eh) : base_t(L, index), m_error_handler(std::move(eh)) {
|
basic_packaged_coroutine(lua_State* L, absolute_index index, handler_t eh) : base_t(L, index), m_error_handler(std::move(eh)) {
|
||||||
#if SOL_IS_ON(SOL_SAFE_REFERENCES_I_)
|
#if SOL_IS_ON(SOL_SAFE_REFERENCES)
|
||||||
constructor_handler handler {};
|
constructor_handler handler {};
|
||||||
stack::check<basic_packaged_coroutine>(L, index, handler);
|
stack::check<basic_packaged_coroutine>(L, index, handler);
|
||||||
#endif // Safety
|
#endif // Safety
|
||||||
}
|
}
|
||||||
basic_packaged_coroutine(lua_State* L, raw_index index)
|
basic_packaged_coroutine(lua_State* L, raw_index index)
|
||||||
: basic_packaged_coroutine(L, index, detail::get_default_handler<reference, is_main_threaded<base_t>::value>(L)) {
|
: basic_packaged_coroutine(L, index, detail::get_default_handler<reference, is_main_threaded<base_t>::value>(L)) {
|
||||||
}
|
}
|
||||||
basic_packaged_coroutine(lua_State* L, raw_index index, handler_t eh) : base_t(L, index), m_error_handler(std::move(eh)) {
|
basic_packaged_coroutine(lua_State* L, raw_index index, handler_t eh) : base_t(L, index), m_error_handler(std::move(eh)) {
|
||||||
#if SOL_IS_ON(SOL_SAFE_REFERENCES_I_)
|
#if SOL_IS_ON(SOL_SAFE_REFERENCES)
|
||||||
constructor_handler handler {};
|
constructor_handler handler {};
|
||||||
stack::check<basic_packaged_coroutine>(L, index, handler);
|
stack::check<basic_packaged_coroutine>(L, index, handler);
|
||||||
#endif // Safety
|
#endif // Safety
|
||||||
}
|
}
|
||||||
basic_packaged_coroutine(lua_State* L, ref_index index)
|
basic_packaged_coroutine(lua_State* L, ref_index index)
|
||||||
: basic_packaged_coroutine(L, index, detail::get_default_handler<reference, is_main_threaded<base_t>::value>(L)) {
|
: basic_packaged_coroutine(L, index, detail::get_default_handler<reference, is_main_threaded<base_t>::value>(L)) {
|
||||||
}
|
}
|
||||||
basic_packaged_coroutine(lua_State* L, ref_index index, handler_t eh) : base_t(L, index), m_error_handler(std::move(eh)) {
|
basic_packaged_coroutine(lua_State* L, ref_index index, handler_t eh) : base_t(L, index), m_error_handler(std::move(eh)) {
|
||||||
#if SOL_IS_ON(SOL_SAFE_REFERENCES_I_)
|
#if SOL_IS_ON(SOL_SAFE_REFERENCES)
|
||||||
auto pp = stack::push_pop(*this);
|
auto pp = stack::push_pop(*this);
|
||||||
constructor_handler handler {};
|
constructor_handler handler {};
|
||||||
stack::check<basic_packaged_coroutine>(lua_state(), -1, handler);
|
stack::check<basic_packaged_coroutine>(lua_state(), -1, handler);
|
||||||
#endif // Safety
|
#endif // Safety
|
||||||
}
|
}
|
||||||
|
|
||||||
call_status status() const noexcept {
|
call_status status() const noexcept {
|
||||||
return stats;
|
return stats;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool error() const noexcept {
|
bool error() const noexcept {
|
||||||
call_status cs = status();
|
call_status cs = status();
|
||||||
return cs != call_status::ok && cs != call_status::yielded;
|
return cs != call_status::ok && cs != call_status::yielded;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool runnable() const noexcept {
|
bool runnable() const noexcept {
|
||||||
return base_t::valid() && (status() == call_status::yielded);
|
return base_t::valid() && (status() == call_status::yielded);
|
||||||
}
|
}
|
||||||
|
|
||||||
reference error_handler() const noexcept {
|
reference error_handler() const noexcept {
|
||||||
return reference(m_L, registry_index(m_error_handler.index));
|
return reference(m_L, registry_index(m_error_handler.index));
|
||||||
}
|
}
|
||||||
|
|
||||||
set_error_handler(reference new_error_handler) noexcept {
|
set_error_handler(reference new_error_handler) noexcept {
|
||||||
this->m_error_handler = stateless_reference(this->m_L, std::move(new_error_handler));
|
this->m_error_handler = stateless_reference(this->m_L, std::move(new_error_handler));
|
||||||
}
|
}
|
||||||
|
|
||||||
explicit operator bool() const noexcept {
|
explicit operator bool() const noexcept {
|
||||||
return runnable();
|
return runnable();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename... Args>
|
template <typename... Args>
|
||||||
protected_function_result operator()(Args&&... args) {
|
protected_function_result operator()(Args&&... args) {
|
||||||
return call<>(std::forward<Args>(args)...);
|
return call<>(std::forward<Args>(args)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename... Ret, typename... Args>
|
template <typename... Ret, typename... Args>
|
||||||
decltype(auto) operator()(types<Ret...>, Args&&... args) {
|
decltype(auto) operator()(types<Ret...>, Args&&... args) {
|
||||||
return call<Ret...>(std::forward<Args>(args)...);
|
return call<Ret...>(std::forward<Args>(args)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename... Ret, typename... Args>
|
template <typename... Ret, typename... Args>
|
||||||
decltype(auto) call(Args&&... args) {
|
decltype(auto) call(Args&&... args) {
|
||||||
// some users screw up coroutine.create
|
// some users screw up coroutine.create
|
||||||
// and try to use it with sol::coroutine without ever calling the first resume in Lua
|
// and try to use it with sol::coroutine without ever calling the first resume in Lua
|
||||||
// this makes the stack incompatible with other kinds of stacks: protect against this
|
// this makes the stack incompatible with other kinds of stacks: protect against this
|
||||||
// make sure coroutines don't screw us over
|
// make sure coroutines don't screw us over
|
||||||
base_t::push();
|
base_t::push();
|
||||||
int pushcount = stack::multi_push_reference(lua_state(), std::forward<Args>(args)...);
|
int pushcount = stack::multi_push_reference(lua_state(), std::forward<Args>(args)...);
|
||||||
return invoke(types<Ret...>(), std::make_index_sequence<sizeof...(Ret)>(), pushcount);
|
return invoke(types<Ret...>(), std::make_index_sequence<sizeof...(Ret)>(), pushcount);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
} // namespace sol
|
} // namespace sol
|
||||||
|
|
||||||
#endif // SOL_PACKAGED_COROUTINE_HPP
|
#endif // SOL_PACKAGED_COROUTINE_HPP
|
||||||
|
|
|
||||||
550
extern/sol3/sol/pairs_iterator.hpp
vendored
550
extern/sol3/sol/pairs_iterator.hpp
vendored
|
|
@ -1,275 +1,275 @@
|
||||||
// sol2
|
// sol2
|
||||||
|
|
||||||
// The MIT License (MIT)
|
// The MIT License (MIT)
|
||||||
|
|
||||||
// Copyright (c) 2013-2021 Rapptz, ThePhD and contributors
|
// Copyright (c) 2013-2022 Rapptz, ThePhD and contributors
|
||||||
|
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
// this software and associated documentation files (the "Software"), to deal in
|
// this software and associated documentation files (the "Software"), to deal in
|
||||||
// the Software without restriction, including without limitation the rights to
|
// the Software without restriction, including without limitation the rights to
|
||||||
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||||
// the Software, and to permit persons to whom the Software is furnished to do so,
|
// the Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
// subject to the following conditions:
|
// subject to the following conditions:
|
||||||
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
// The above copyright notice and this permission notice shall be included in all
|
||||||
// copies or substantial portions of the Software.
|
// copies or substantial portions of the Software.
|
||||||
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
#ifndef SOL_PAIRS_ITERATOR_HPP
|
#ifndef SOL_PAIRS_ITERATOR_HPP
|
||||||
#define SOL_PAIRS_ITERATOR_HPP
|
#define SOL_PAIRS_ITERATOR_HPP
|
||||||
|
|
||||||
#include <sol/version.hpp>
|
#include <sol/version.hpp>
|
||||||
|
|
||||||
#include <sol/reference.hpp>
|
#include <sol/reference.hpp>
|
||||||
#include <sol/stack_reference.hpp>
|
#include <sol/stack_reference.hpp>
|
||||||
#include <sol/table_iterator.hpp>
|
#include <sol/table_iterator.hpp>
|
||||||
#include <sol/protected_function.hpp>
|
#include <sol/protected_function.hpp>
|
||||||
|
|
||||||
#include <sol/stack/detail/pairs.hpp>
|
#include <sol/stack/detail/pairs.hpp>
|
||||||
|
|
||||||
namespace sol {
|
namespace sol {
|
||||||
|
|
||||||
struct pairs_sentinel { };
|
struct pairs_sentinel { };
|
||||||
|
|
||||||
class pairs_iterator {
|
class pairs_iterator {
|
||||||
private:
|
private:
|
||||||
inline static constexpr int empty_key_index = -1;
|
inline static constexpr int empty_key_index = -1;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
using key_type = object;
|
using key_type = object;
|
||||||
using mapped_type = object;
|
using mapped_type = object;
|
||||||
using value_type = std::pair<object, object>;
|
using value_type = std::pair<object, object>;
|
||||||
using iterator_category = std::input_iterator_tag;
|
using iterator_category = std::input_iterator_tag;
|
||||||
using difference_type = std::ptrdiff_t;
|
using difference_type = std::ptrdiff_t;
|
||||||
using pointer = value_type*;
|
using pointer = value_type*;
|
||||||
using const_pointer = value_type const*;
|
using const_pointer = value_type const*;
|
||||||
using reference = value_type&;
|
using reference = value_type&;
|
||||||
using const_reference = const value_type&;
|
using const_reference = const value_type&;
|
||||||
|
|
||||||
pairs_iterator() noexcept
|
pairs_iterator() noexcept
|
||||||
: m_L(nullptr)
|
: m_L(nullptr)
|
||||||
, m_next_function_ref(lua_nil)
|
, m_next_function_ref(lua_nil)
|
||||||
, m_table_ref(lua_nil)
|
, m_table_ref(lua_nil)
|
||||||
, m_cached_key_value_pair({ lua_nil, lua_nil })
|
, m_cached_key_value_pair({ lua_nil, lua_nil })
|
||||||
, m_key_index(empty_key_index)
|
, m_key_index(empty_key_index)
|
||||||
, m_iteration_index(0) {
|
, m_iteration_index(0) {
|
||||||
}
|
}
|
||||||
|
|
||||||
pairs_iterator(const pairs_iterator&) = delete;
|
pairs_iterator(const pairs_iterator&) = delete;
|
||||||
pairs_iterator& operator=(const pairs_iterator&) = delete;
|
pairs_iterator& operator=(const pairs_iterator&) = delete;
|
||||||
|
|
||||||
pairs_iterator(pairs_iterator&& right) noexcept
|
pairs_iterator(pairs_iterator&& right) noexcept
|
||||||
: m_L(right.m_L)
|
: m_L(right.m_L)
|
||||||
, m_next_function_ref(std::move(right.m_next_function_ref))
|
, m_next_function_ref(std::move(right.m_next_function_ref))
|
||||||
, m_table_ref(std::move(right.m_table_ref))
|
, m_table_ref(std::move(right.m_table_ref))
|
||||||
, m_cached_key_value_pair(std::move(right.m_cached_key_value_pair))
|
, m_cached_key_value_pair(std::move(right.m_cached_key_value_pair))
|
||||||
, m_key_index(right.m_key_index)
|
, m_key_index(right.m_key_index)
|
||||||
, m_iteration_index(right.m_iteration_index) {
|
, m_iteration_index(right.m_iteration_index) {
|
||||||
right.m_key_index = empty_key_index;
|
right.m_key_index = empty_key_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
pairs_iterator& operator=(pairs_iterator&& right) noexcept {
|
pairs_iterator& operator=(pairs_iterator&& right) noexcept {
|
||||||
m_L = right.m_L;
|
m_L = right.m_L;
|
||||||
m_next_function_ref = std::move(right.m_next_function_ref);
|
m_next_function_ref = std::move(right.m_next_function_ref);
|
||||||
m_table_ref = std::move(right.m_table_ref);
|
m_table_ref = std::move(right.m_table_ref);
|
||||||
m_cached_key_value_pair = std::move(right.m_cached_key_value_pair);
|
m_cached_key_value_pair = std::move(right.m_cached_key_value_pair);
|
||||||
m_key_index = right.m_key_index;
|
m_key_index = right.m_key_index;
|
||||||
m_iteration_index = right.m_iteration_index;
|
m_iteration_index = right.m_iteration_index;
|
||||||
right.m_key_index = empty_key_index;
|
right.m_key_index = empty_key_index;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Source>
|
template <typename Source>
|
||||||
pairs_iterator(const Source& source_) noexcept : m_L(source_.lua_state()), m_key_index(empty_key_index), m_iteration_index(0) {
|
pairs_iterator(const Source& source_) noexcept : m_L(source_.lua_state()), m_key_index(empty_key_index), m_iteration_index(0) {
|
||||||
if (m_L == nullptr || !source_.valid()) {
|
if (m_L == nullptr || !source_.valid()) {
|
||||||
m_key_index = empty_key_index;
|
m_key_index = empty_key_index;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int source_index = -source_.push(m_L);
|
int source_index = -source_.push(m_L);
|
||||||
int abs_source_index = lua_absindex(m_L, source_index);
|
int abs_source_index = lua_absindex(m_L, source_index);
|
||||||
int metatable_exists = lua_getmetatable(m_L, abs_source_index);
|
int metatable_exists = lua_getmetatable(m_L, abs_source_index);
|
||||||
lua_remove(m_L, abs_source_index);
|
lua_remove(m_L, abs_source_index);
|
||||||
if (metatable_exists == 1) {
|
if (metatable_exists == 1) {
|
||||||
// just has a metatable, but does it have __pairs ?
|
// just has a metatable, but does it have __pairs ?
|
||||||
stack_reference metatable(m_L, raw_index(abs_source_index));
|
stack_reference metatable(m_L, raw_index(abs_source_index));
|
||||||
stack::get_field<is_global_table_v<Source>, true>(m_L, meta_function::pairs, metatable.stack_index());
|
stack::get_field<is_global_table_v<Source>, true>(m_L, meta_function::pairs, metatable.stack_index());
|
||||||
optional<protected_function> maybe_pairs_function = stack::pop<optional<protected_function>>(m_L);
|
optional<protected_function> maybe_pairs_function = stack::pop<optional<protected_function>>(m_L);
|
||||||
if (maybe_pairs_function.has_value()) {
|
if (maybe_pairs_function.has_value()) {
|
||||||
protected_function& pairs_function = *maybe_pairs_function;
|
protected_function& pairs_function = *maybe_pairs_function;
|
||||||
protected_function_result next_fn_and_table_and_first_key = pairs_function(source_);
|
protected_function_result next_fn_and_table_and_first_key = pairs_function(source_);
|
||||||
if (next_fn_and_table_and_first_key.valid()) {
|
if (next_fn_and_table_and_first_key.valid()) {
|
||||||
m_next_function_ref = next_fn_and_table_and_first_key.get<protected_function>(0);
|
m_next_function_ref = next_fn_and_table_and_first_key.get<protected_function>(0);
|
||||||
m_table_ref = next_fn_and_table_and_first_key.get<sol::reference>(1);
|
m_table_ref = next_fn_and_table_and_first_key.get<sol::reference>(1);
|
||||||
m_key_index = next_fn_and_table_and_first_key.stack_index() - 1;
|
m_key_index = next_fn_and_table_and_first_key.stack_index() - 1;
|
||||||
// remove next function and table
|
// remove next function and table
|
||||||
lua_remove(m_L, m_key_index);
|
lua_remove(m_L, m_key_index);
|
||||||
lua_remove(m_L, m_key_index);
|
lua_remove(m_L, m_key_index);
|
||||||
next_fn_and_table_and_first_key.abandon();
|
next_fn_and_table_and_first_key.abandon();
|
||||||
lua_remove(m_L, abs_source_index);
|
lua_remove(m_L, abs_source_index);
|
||||||
this->operator++();
|
this->operator++();
|
||||||
m_iteration_index = 0;
|
m_iteration_index = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
auto maybe_next = stack::stack_detail::find_lua_next_function(m_L);
|
auto maybe_next = stack::stack_detail::find_lua_next_function(m_L);
|
||||||
if (maybe_next.has_value()) {
|
if (maybe_next.has_value()) {
|
||||||
m_next_function_ref = std::move(*maybe_next);
|
m_next_function_ref = std::move(*maybe_next);
|
||||||
m_table_ref = source_;
|
m_table_ref = source_;
|
||||||
|
|
||||||
stack::push(m_L, lua_nil);
|
stack::push(m_L, lua_nil);
|
||||||
m_key_index = lua_gettop(m_L);
|
m_key_index = lua_gettop(m_L);
|
||||||
this->operator++();
|
this->operator++();
|
||||||
m_iteration_index = 0;
|
m_iteration_index = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// okay, so none of the above worked and now we need to create
|
// okay, so none of the above worked and now we need to create
|
||||||
// a shim / polyfill instead
|
// a shim / polyfill instead
|
||||||
stack::push(m_L, &stack::stack_detail::c_lua_next);
|
stack::push(m_L, &stack::stack_detail::c_lua_next);
|
||||||
m_next_function_ref = stack::pop<protected_function>(m_L);
|
m_next_function_ref = stack::pop<protected_function>(m_L);
|
||||||
m_table_ref = source_;
|
m_table_ref = source_;
|
||||||
stack::push(m_L, lua_nil);
|
stack::push(m_L, lua_nil);
|
||||||
m_key_index = lua_gettop(m_L);
|
m_key_index = lua_gettop(m_L);
|
||||||
this->operator++();
|
this->operator++();
|
||||||
m_iteration_index = 0;
|
m_iteration_index = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
pairs_iterator& operator++() {
|
pairs_iterator& operator++() {
|
||||||
if (m_key_index == empty_key_index) {
|
if (m_key_index == empty_key_index) {
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
sol::protected_function_result next_results = m_next_function_ref(m_table_ref, stack_reference(m_L, m_key_index));
|
sol::protected_function_result next_results = m_next_function_ref(m_table_ref, stack_reference(m_L, m_key_index));
|
||||||
if (!next_results.valid()) {
|
if (!next_results.valid()) {
|
||||||
// TODO: abort, or throw an error?
|
// TODO: abort, or throw an error?
|
||||||
m_clear();
|
m_clear();
|
||||||
m_key_index = empty_key_index;
|
m_key_index = empty_key_index;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
int next_results_count = next_results.return_count();
|
int next_results_count = next_results.return_count();
|
||||||
if (next_results_count < 2) {
|
if (next_results_count < 2) {
|
||||||
// iteration is over!
|
// iteration is over!
|
||||||
next_results.abandon();
|
next_results.abandon();
|
||||||
lua_settop(m_L, m_key_index - 1);
|
lua_settop(m_L, m_key_index - 1);
|
||||||
m_key_index = empty_key_index;
|
m_key_index = empty_key_index;
|
||||||
++m_iteration_index;
|
++m_iteration_index;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
lua_remove(m_L, m_key_index);
|
lua_remove(m_L, m_key_index);
|
||||||
m_key_index = next_results.stack_index() - 1;
|
m_key_index = next_results.stack_index() - 1;
|
||||||
m_cached_key_value_pair.first = stack::get<object>(m_L, m_key_index);
|
m_cached_key_value_pair.first = stack::get<object>(m_L, m_key_index);
|
||||||
m_cached_key_value_pair.second = stack::get<object>(m_L, m_key_index + 1);
|
m_cached_key_value_pair.second = stack::get<object>(m_L, m_key_index + 1);
|
||||||
lua_settop(m_L, m_key_index);
|
lua_settop(m_L, m_key_index);
|
||||||
next_results.abandon();
|
next_results.abandon();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
++m_iteration_index;
|
++m_iteration_index;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::ptrdiff_t index() const {
|
std::ptrdiff_t index() const {
|
||||||
return static_cast<std::ptrdiff_t>(m_iteration_index);
|
return static_cast<std::ptrdiff_t>(m_iteration_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
const_reference operator*() const noexcept {
|
const_reference operator*() const noexcept {
|
||||||
return m_cached_key_value_pair;
|
return m_cached_key_value_pair;
|
||||||
}
|
}
|
||||||
|
|
||||||
reference operator*() noexcept {
|
reference operator*() noexcept {
|
||||||
return m_cached_key_value_pair;
|
return m_cached_key_value_pair;
|
||||||
}
|
}
|
||||||
|
|
||||||
friend bool operator==(const pairs_iterator& left, const pairs_iterator& right) noexcept {
|
friend bool operator==(const pairs_iterator& left, const pairs_iterator& right) noexcept {
|
||||||
return left.m_table_ref == right.m_table_ref && left.m_iteration_index == right.m_iteration_index;
|
return left.m_table_ref == right.m_table_ref && left.m_iteration_index == right.m_iteration_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
friend bool operator!=(const pairs_iterator& left, const pairs_iterator& right) noexcept {
|
friend bool operator!=(const pairs_iterator& left, const pairs_iterator& right) noexcept {
|
||||||
return left.m_table_ref != right.m_table_ref || left.m_iteration_index != right.m_iteration_index;
|
return left.m_table_ref != right.m_table_ref || left.m_iteration_index != right.m_iteration_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
friend bool operator==(const pairs_iterator& left, const pairs_sentinel&) noexcept {
|
friend bool operator==(const pairs_iterator& left, const pairs_sentinel&) noexcept {
|
||||||
return left.m_key_index == empty_key_index;
|
return left.m_key_index == empty_key_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
friend bool operator!=(const pairs_iterator& left, const pairs_sentinel&) noexcept {
|
friend bool operator!=(const pairs_iterator& left, const pairs_sentinel&) noexcept {
|
||||||
return left.m_key_index != empty_key_index;
|
return left.m_key_index != empty_key_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
friend bool operator==(const pairs_sentinel&, const pairs_iterator& left) noexcept {
|
friend bool operator==(const pairs_sentinel&, const pairs_iterator& left) noexcept {
|
||||||
return left.m_key_index == empty_key_index;
|
return left.m_key_index == empty_key_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
friend bool operator!=(const pairs_sentinel&, const pairs_iterator& left) noexcept {
|
friend bool operator!=(const pairs_sentinel&, const pairs_iterator& left) noexcept {
|
||||||
return left.m_key_index != empty_key_index;
|
return left.m_key_index != empty_key_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
~pairs_iterator() {
|
~pairs_iterator() {
|
||||||
if (m_key_index != empty_key_index) {
|
if (m_key_index != empty_key_index) {
|
||||||
m_clear();
|
m_clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void m_clear() noexcept {
|
void m_clear() noexcept {
|
||||||
lua_remove(m_L, m_key_index);
|
lua_remove(m_L, m_key_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
lua_State* m_L;
|
lua_State* m_L;
|
||||||
protected_function m_next_function_ref;
|
protected_function m_next_function_ref;
|
||||||
sol::reference m_table_ref;
|
sol::reference m_table_ref;
|
||||||
std::pair<object, object> m_cached_key_value_pair;
|
std::pair<object, object> m_cached_key_value_pair;
|
||||||
int m_key_index;
|
int m_key_index;
|
||||||
int m_iteration_index;
|
int m_iteration_index;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename Source>
|
template <typename Source>
|
||||||
class basic_pairs_range {
|
class basic_pairs_range {
|
||||||
private:
|
private:
|
||||||
using source_t = std::add_lvalue_reference_t<Source>;
|
using source_t = std::add_lvalue_reference_t<Source>;
|
||||||
source_t m_source;
|
source_t m_source;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
using iterator = pairs_iterator;
|
using iterator = pairs_iterator;
|
||||||
using const_iterator = pairs_iterator;
|
using const_iterator = pairs_iterator;
|
||||||
|
|
||||||
basic_pairs_range(source_t source_) noexcept : m_source(source_) {
|
basic_pairs_range(source_t source_) noexcept : m_source(source_) {
|
||||||
}
|
}
|
||||||
|
|
||||||
iterator begin() noexcept {
|
iterator begin() noexcept {
|
||||||
return iterator(m_source);
|
return iterator(m_source);
|
||||||
}
|
}
|
||||||
|
|
||||||
iterator begin() const noexcept {
|
iterator begin() const noexcept {
|
||||||
return iterator(m_source);
|
return iterator(m_source);
|
||||||
}
|
}
|
||||||
|
|
||||||
const_iterator cbegin() const noexcept {
|
const_iterator cbegin() const noexcept {
|
||||||
return const_iterator(m_source);
|
return const_iterator(m_source);
|
||||||
}
|
}
|
||||||
|
|
||||||
pairs_sentinel end() noexcept {
|
pairs_sentinel end() noexcept {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
pairs_sentinel end() const noexcept {
|
pairs_sentinel end() const noexcept {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
pairs_sentinel cend() const noexcept {
|
pairs_sentinel cend() const noexcept {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} // namespace sol
|
} // namespace sol
|
||||||
|
|
||||||
#endif // SOL_PAIRS_ITERATOR_HPP
|
#endif // SOL_PAIRS_ITERATOR_HPP
|
||||||
|
|
|
||||||
205
extern/sol3/sol/pointer_like.hpp
vendored
205
extern/sol3/sol/pointer_like.hpp
vendored
|
|
@ -1,102 +1,103 @@
|
||||||
// sol2
|
// sol2
|
||||||
|
|
||||||
// The MIT License (MIT)
|
// The MIT License (MIT)
|
||||||
|
|
||||||
// Copyright (c) 2013-2021 Rapptz, ThePhD and contributors
|
// Copyright (c) 2013-2022 Rapptz, ThePhD and contributors
|
||||||
|
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
// this software and associated documentation files (the "Software"), to deal in
|
// this software and associated documentation files (the "Software"), to deal in
|
||||||
// the Software without restriction, including without limitation the rights to
|
// the Software without restriction, including without limitation the rights to
|
||||||
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||||
// the Software, and to permit persons to whom the Software is furnished to do so,
|
// the Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
// subject to the following conditions:
|
// subject to the following conditions:
|
||||||
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
// The above copyright notice and this permission notice shall be included in all
|
||||||
// copies or substantial portions of the Software.
|
// copies or substantial portions of the Software.
|
||||||
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
#ifndef SOL_POINTER_LIKE_HPP
|
#ifndef SOL_POINTER_LIKE_HPP
|
||||||
#define SOL_POINTER_LIKE_HPP
|
#define SOL_POINTER_LIKE_HPP
|
||||||
|
|
||||||
#include <sol/base_traits.hpp>
|
#include <sol/base_traits.hpp>
|
||||||
|
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
|
#include <memory>
|
||||||
namespace sol {
|
|
||||||
|
namespace sol {
|
||||||
namespace meta {
|
|
||||||
namespace meta_detail {
|
namespace meta {
|
||||||
template <typename T>
|
namespace meta_detail {
|
||||||
using is_dereferenceable_test = decltype(*std::declval<T>());
|
template <typename T>
|
||||||
|
using is_dereferenceable_test = decltype(*std::declval<T>());
|
||||||
template <typename T>
|
|
||||||
using is_explicitly_dereferenceable_test = decltype(std::declval<T>().operator*());
|
template <typename T>
|
||||||
} // namespace meta_detail
|
using is_explicitly_dereferenceable_test = decltype(std::declval<T>().operator*());
|
||||||
|
} // namespace meta_detail
|
||||||
template <typename T>
|
|
||||||
using is_pointer_like = std::integral_constant<bool,
|
template <typename T>
|
||||||
!std::is_array_v<T> && (std::is_pointer_v<T> || is_detected_v<meta_detail::is_explicitly_dereferenceable_test, T>)>;
|
using is_pointer_like = std::integral_constant<bool,
|
||||||
|
!std::is_array_v<T> && (std::is_pointer_v<T> || is_detected_v<meta_detail::is_explicitly_dereferenceable_test, T>)>;
|
||||||
template <typename T>
|
|
||||||
constexpr inline bool is_pointer_like_v = is_pointer_like<T>::value;
|
template <typename T>
|
||||||
} // namespace meta
|
constexpr inline bool is_pointer_like_v = is_pointer_like<T>::value;
|
||||||
|
} // namespace meta
|
||||||
namespace detail {
|
|
||||||
|
namespace detail {
|
||||||
template <typename T>
|
|
||||||
auto unwrap(T&& item) -> decltype(std::forward<T>(item)) {
|
template <typename T>
|
||||||
return std::forward<T>(item);
|
auto unwrap(T&& item) -> decltype(std::forward<T>(item)) {
|
||||||
}
|
return std::forward<T>(item);
|
||||||
|
}
|
||||||
template <typename T>
|
|
||||||
T& unwrap(std::reference_wrapper<T> arg) {
|
template <typename T>
|
||||||
return arg.get();
|
T& unwrap(std::reference_wrapper<T> arg) {
|
||||||
}
|
return arg.get();
|
||||||
|
}
|
||||||
template <typename T>
|
|
||||||
inline decltype(auto) deref(T&& item) {
|
template <typename T>
|
||||||
using Tu = meta::unqualified_t<T>;
|
inline decltype(auto) deref(T&& item) {
|
||||||
if constexpr (meta::is_pointer_like_v<Tu>) {
|
using Tu = meta::unqualified_t<T>;
|
||||||
return *std::forward<T>(item);
|
if constexpr (meta::is_pointer_like_v<Tu>) {
|
||||||
}
|
return *std::forward<T>(item);
|
||||||
else {
|
}
|
||||||
return std::forward<T>(item);
|
else {
|
||||||
}
|
return std::forward<T>(item);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
template <typename T>
|
|
||||||
inline decltype(auto) deref_move_only(T&& item) {
|
template <typename T>
|
||||||
using Tu = meta::unqualified_t<T>;
|
inline decltype(auto) deref_move_only(T&& item) {
|
||||||
if constexpr (meta::is_pointer_like_v<Tu> && !std::is_pointer_v<Tu> && !std::is_copy_constructible_v<Tu>) {
|
using Tu = meta::unqualified_t<T>;
|
||||||
return *std::forward<T>(item);
|
if constexpr (meta::is_pointer_like_v<Tu> && !std::is_pointer_v<Tu> && !std::is_copy_constructible_v<Tu>) {
|
||||||
}
|
return *std::forward<T>(item);
|
||||||
else {
|
}
|
||||||
return std::forward<T>(item);
|
else {
|
||||||
}
|
return std::forward<T>(item);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
template <typename T>
|
|
||||||
inline T* ptr(T& val) {
|
template <typename T>
|
||||||
return std::addressof(val);
|
inline T* ptr(T& val) {
|
||||||
}
|
return std::addressof(val);
|
||||||
|
}
|
||||||
template <typename T>
|
|
||||||
inline T* ptr(std::reference_wrapper<T> val) {
|
template <typename T>
|
||||||
return std::addressof(val.get());
|
inline T* ptr(std::reference_wrapper<T> val) {
|
||||||
}
|
return std::addressof(val.get());
|
||||||
|
}
|
||||||
template <typename T>
|
|
||||||
inline T* ptr(T* val) {
|
template <typename T>
|
||||||
return val;
|
inline T* ptr(T* val) {
|
||||||
}
|
return val;
|
||||||
} // namespace detail
|
}
|
||||||
} // namespace sol
|
} // namespace detail
|
||||||
|
} // namespace sol
|
||||||
#endif // SOL_POINTER_LIKE_HPP
|
|
||||||
|
#endif // SOL_POINTER_LIKE_HPP
|
||||||
|
|
|
||||||
2
extern/sol3/sol/policies.hpp
vendored
2
extern/sol3/sol/policies.hpp
vendored
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
// The MIT License (MIT)
|
// The MIT License (MIT)
|
||||||
|
|
||||||
// Copyright (c) 2013-2021 Rapptz, ThePhD and contributors
|
// Copyright (c) 2013-2022 Rapptz, ThePhD and contributors
|
||||||
|
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
// this software and associated documentation files (the "Software"), to deal in
|
// this software and associated documentation files (the "Software"), to deal in
|
||||||
|
|
|
||||||
94
extern/sol3/sol/prologue.hpp
vendored
94
extern/sol3/sol/prologue.hpp
vendored
|
|
@ -1,47 +1,47 @@
|
||||||
// sol2
|
// sol2
|
||||||
|
|
||||||
// The MIT License (MIT)
|
// The MIT License (MIT)
|
||||||
|
|
||||||
// Copyright (c) 2013-2021 Rapptz, ThePhD and contributors
|
// Copyright (c) 2013-2022 Rapptz, ThePhD and contributors
|
||||||
|
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
// this software and associated documentation files (the "Software"), to deal in
|
// this software and associated documentation files (the "Software"), to deal in
|
||||||
// the Software without restriction, including without limitation the rights to
|
// the Software without restriction, including without limitation the rights to
|
||||||
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||||
// the Software, and to permit persons to whom the Software is furnished to do so,
|
// the Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
// subject to the following conditions:
|
// subject to the following conditions:
|
||||||
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
// The above copyright notice and this permission notice shall be included in all
|
||||||
// copies or substantial portions of the Software.
|
// copies or substantial portions of the Software.
|
||||||
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
|
|
||||||
#if defined(SOL_PROLOGUE_I_)
|
#if defined(SOL_PROLOGUE_I_)
|
||||||
#error "[sol2] Library Prologue was already included in translation unit and not properly ended with an epilogue."
|
#error "[sol2] Library Prologue was already included in translation unit and not properly ended with an epilogue."
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define SOL_PROLOGUE_I_ 1
|
#define SOL_PROLOGUE_I_ 1
|
||||||
|
|
||||||
|
|
||||||
#if SOL_IS_ON(SOL_BUILD_CXX_MODE_I_)
|
#if SOL_IS_ON(SOL_BUILD_CXX_MODE)
|
||||||
#define _FWD(...) static_cast<decltype( __VA_ARGS__ )&&>( __VA_ARGS__ )
|
#define _FWD(...) static_cast<decltype( __VA_ARGS__ )&&>( __VA_ARGS__ )
|
||||||
|
|
||||||
#if SOL_IS_ON(SOL_COMPILER_GCC_I_) || SOL_IS_ON(SOL_COMPILER_CLANG_I_)
|
#if SOL_IS_ON(SOL_COMPILER_GCC) || SOL_IS_ON(SOL_COMPILER_CLANG)
|
||||||
#define _MOVE(...) static_cast<__typeof( __VA_ARGS__ )&&>( __VA_ARGS__ )
|
#define _MOVE(...) static_cast<__typeof( __VA_ARGS__ )&&>( __VA_ARGS__ )
|
||||||
#else
|
#else
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
|
|
||||||
#define _MOVE(...) static_cast<::std::remove_reference_t<( __VA_ARGS__ )>&&>( __VA_OPT__(,) )
|
#define _MOVE(...) static_cast<::std::remove_reference_t<( __VA_ARGS__ )>&&>( __VA_OPT__(,) )
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
|
||||||
2
extern/sol3/sol/property.hpp
vendored
2
extern/sol3/sol/property.hpp
vendored
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
// The MIT License (MIT)
|
// The MIT License (MIT)
|
||||||
|
|
||||||
// Copyright (c) 2013-2021 Rapptz, ThePhD and contributors
|
// Copyright (c) 2013-2022 Rapptz, ThePhD and contributors
|
||||||
|
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
// this software and associated documentation files (the "Software"), to deal in
|
// this software and associated documentation files (the "Software"), to deal in
|
||||||
|
|
|
||||||
2
extern/sol3/sol/protect.hpp
vendored
2
extern/sol3/sol/protect.hpp
vendored
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
// The MIT License (MIT)
|
// The MIT License (MIT)
|
||||||
|
|
||||||
// Copyright (c) 2013-2021 Rapptz, ThePhD and contributors
|
// Copyright (c) 2013-2022 Rapptz, ThePhD and contributors
|
||||||
|
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
// this software and associated documentation files (the "Software"), to deal in
|
// this software and associated documentation files (the "Software"), to deal in
|
||||||
|
|
|
||||||
20
extern/sol3/sol/protected_function.hpp
vendored
20
extern/sol3/sol/protected_function.hpp
vendored
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
// The MIT License (MIT)
|
// The MIT License (MIT)
|
||||||
|
|
||||||
// Copyright (c) 2013-2021 Rapptz, ThePhD and contributors
|
// Copyright (c) 2013-2022 Rapptz, ThePhD and contributors
|
||||||
|
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
// this software and associated documentation files (the "Software"), to deal in
|
// this software and associated documentation files (the "Software"), to deal in
|
||||||
|
|
@ -75,7 +75,7 @@ namespace sol {
|
||||||
meta::neg<std::is_base_of<proxy_base_tag, meta::unqualified_t<T>>>, meta::neg<std::is_same<base_t, stack_reference>>,
|
meta::neg<std::is_base_of<proxy_base_tag, meta::unqualified_t<T>>>, meta::neg<std::is_same<base_t, stack_reference>>,
|
||||||
meta::neg<std::is_same<lua_nil_t, meta::unqualified_t<T>>>, is_lua_reference<meta::unqualified_t<T>>> = meta::enabler>
|
meta::neg<std::is_same<lua_nil_t, meta::unqualified_t<T>>>, is_lua_reference<meta::unqualified_t<T>>> = meta::enabler>
|
||||||
basic_protected_function(T&& r) noexcept : base_t(std::forward<T>(r)), m_error_handler(get_default_handler(r.lua_state())) {
|
basic_protected_function(T&& r) noexcept : base_t(std::forward<T>(r)), m_error_handler(get_default_handler(r.lua_state())) {
|
||||||
#if SOL_IS_ON(SOL_SAFE_REFERENCES_I_)
|
#if SOL_IS_ON(SOL_SAFE_REFERENCES)
|
||||||
if (!is_function<meta::unqualified_t<T>>::value) {
|
if (!is_function<meta::unqualified_t<T>>::value) {
|
||||||
auto pp = stack::push_pop(*this);
|
auto pp = stack::push_pop(*this);
|
||||||
constructor_handler handler {};
|
constructor_handler handler {};
|
||||||
|
|
@ -133,7 +133,7 @@ namespace sol {
|
||||||
}
|
}
|
||||||
template <typename T, meta::enable<is_lua_reference<meta::unqualified_t<T>>> = meta::enabler>
|
template <typename T, meta::enable<is_lua_reference<meta::unqualified_t<T>>> = meta::enabler>
|
||||||
basic_protected_function(lua_State* L_, T&& r, handler_t eh) : base_t(L_, std::forward<T>(r)), m_error_handler(std::move(eh)) {
|
basic_protected_function(lua_State* L_, T&& r, handler_t eh) : base_t(L_, std::forward<T>(r)), m_error_handler(std::move(eh)) {
|
||||||
#if SOL_IS_ON(SOL_SAFE_REFERENCES_I_)
|
#if SOL_IS_ON(SOL_SAFE_REFERENCES)
|
||||||
auto pp = stack::push_pop(*this);
|
auto pp = stack::push_pop(*this);
|
||||||
constructor_handler handler {};
|
constructor_handler handler {};
|
||||||
stack::check<basic_protected_function>(lua_state(), -1, handler);
|
stack::check<basic_protected_function>(lua_state(), -1, handler);
|
||||||
|
|
@ -146,7 +146,7 @@ namespace sol {
|
||||||
basic_protected_function(lua_State* L_, int index_ = -1) : basic_protected_function(L_, index_, get_default_handler(L_)) {
|
basic_protected_function(lua_State* L_, int index_ = -1) : basic_protected_function(L_, index_, get_default_handler(L_)) {
|
||||||
}
|
}
|
||||||
basic_protected_function(lua_State* L_, int index_, handler_t eh) : base_t(L_, index_), m_error_handler(std::move(eh)) {
|
basic_protected_function(lua_State* L_, int index_, handler_t eh) : base_t(L_, index_), m_error_handler(std::move(eh)) {
|
||||||
#if SOL_IS_ON(SOL_SAFE_REFERENCES_I_)
|
#if SOL_IS_ON(SOL_SAFE_REFERENCES)
|
||||||
constructor_handler handler {};
|
constructor_handler handler {};
|
||||||
stack::check<basic_protected_function>(L_, index_, handler);
|
stack::check<basic_protected_function>(L_, index_, handler);
|
||||||
#endif // Safety
|
#endif // Safety
|
||||||
|
|
@ -154,7 +154,7 @@ namespace sol {
|
||||||
basic_protected_function(lua_State* L_, absolute_index index_) : basic_protected_function(L_, index_, get_default_handler(L_)) {
|
basic_protected_function(lua_State* L_, absolute_index index_) : basic_protected_function(L_, index_, get_default_handler(L_)) {
|
||||||
}
|
}
|
||||||
basic_protected_function(lua_State* L_, absolute_index index_, handler_t eh) : base_t(L_, index_), m_error_handler(std::move(eh)) {
|
basic_protected_function(lua_State* L_, absolute_index index_, handler_t eh) : base_t(L_, index_), m_error_handler(std::move(eh)) {
|
||||||
#if SOL_IS_ON(SOL_SAFE_REFERENCES_I_)
|
#if SOL_IS_ON(SOL_SAFE_REFERENCES)
|
||||||
constructor_handler handler {};
|
constructor_handler handler {};
|
||||||
stack::check<basic_protected_function>(L_, index_, handler);
|
stack::check<basic_protected_function>(L_, index_, handler);
|
||||||
#endif // Safety
|
#endif // Safety
|
||||||
|
|
@ -162,7 +162,7 @@ namespace sol {
|
||||||
basic_protected_function(lua_State* L_, raw_index index_) : basic_protected_function(L_, index_, get_default_handler(L_)) {
|
basic_protected_function(lua_State* L_, raw_index index_) : basic_protected_function(L_, index_, get_default_handler(L_)) {
|
||||||
}
|
}
|
||||||
basic_protected_function(lua_State* L_, raw_index index_, handler_t eh) : base_t(L_, index_), m_error_handler(std::move(eh)) {
|
basic_protected_function(lua_State* L_, raw_index index_, handler_t eh) : base_t(L_, index_), m_error_handler(std::move(eh)) {
|
||||||
#if SOL_IS_ON(SOL_SAFE_REFERENCES_I_)
|
#if SOL_IS_ON(SOL_SAFE_REFERENCES)
|
||||||
constructor_handler handler {};
|
constructor_handler handler {};
|
||||||
stack::check<basic_protected_function>(L_, index_, handler);
|
stack::check<basic_protected_function>(L_, index_, handler);
|
||||||
#endif // Safety
|
#endif // Safety
|
||||||
|
|
@ -170,7 +170,7 @@ namespace sol {
|
||||||
basic_protected_function(lua_State* L_, ref_index index_) : basic_protected_function(L_, index_, get_default_handler(L_)) {
|
basic_protected_function(lua_State* L_, ref_index index_) : basic_protected_function(L_, index_, get_default_handler(L_)) {
|
||||||
}
|
}
|
||||||
basic_protected_function(lua_State* L_, ref_index index_, handler_t eh) : base_t(L_, index_), m_error_handler(std::move(eh)) {
|
basic_protected_function(lua_State* L_, ref_index index_, handler_t eh) : base_t(L_, index_), m_error_handler(std::move(eh)) {
|
||||||
#if SOL_IS_ON(SOL_SAFE_REFERENCES_I_)
|
#if SOL_IS_ON(SOL_SAFE_REFERENCES)
|
||||||
auto pp = stack::push_pop(*this);
|
auto pp = stack::push_pop(*this);
|
||||||
constructor_handler handler {};
|
constructor_handler handler {};
|
||||||
stack::check<basic_protected_function>(lua_state(), -1, handler);
|
stack::check<basic_protected_function>(lua_state(), -1, handler);
|
||||||
|
|
@ -339,14 +339,14 @@ namespace sol {
|
||||||
int firstreturn = 1;
|
int firstreturn = 1;
|
||||||
int returncount = 0;
|
int returncount = 0;
|
||||||
call_status code = call_status::ok;
|
call_status code = call_status::ok;
|
||||||
#if SOL_IS_ON(SOL_EXCEPTIONS_I_) && SOL_IS_OFF(SOL_PROPAGATE_EXCEPTIONS_I_)
|
#if SOL_IS_ON(SOL_EXCEPTIONS) && SOL_IS_OFF(SOL_PROPAGATE_EXCEPTIONS)
|
||||||
try {
|
try {
|
||||||
#endif // No Exceptions
|
#endif // No Exceptions
|
||||||
firstreturn = (std::max)(1, static_cast<int>(stacksize - n - static_cast<int>(h.valid() && !is_stack_handler_v)));
|
firstreturn = (std::max)(1, static_cast<int>(stacksize - n - static_cast<int>(h.valid() && !is_stack_handler_v)));
|
||||||
code = luacall(n, LUA_MULTRET, h);
|
code = luacall(n, LUA_MULTRET, h);
|
||||||
poststacksize = lua_gettop(lua_state()) - static_cast<int>(h.valid() && !is_stack_handler_v);
|
poststacksize = lua_gettop(lua_state()) - static_cast<int>(h.valid() && !is_stack_handler_v);
|
||||||
returncount = poststacksize - (firstreturn - 1);
|
returncount = poststacksize - (firstreturn - 1);
|
||||||
#if SOL_IS_ON(SOL_EXCEPTIONS_I_) && SOL_IS_OFF(SOL_PROPAGATE_EXCEPTIONS_I_)
|
#if SOL_IS_ON(SOL_EXCEPTIONS) && SOL_IS_OFF(SOL_PROPAGATE_EXCEPTIONS)
|
||||||
}
|
}
|
||||||
// Handle C++ errors thrown from C++ functions bound inside of lua
|
// Handle C++ errors thrown from C++ functions bound inside of lua
|
||||||
catch (const char* error) {
|
catch (const char* error) {
|
||||||
|
|
@ -364,7 +364,7 @@ namespace sol {
|
||||||
firstreturn = lua_gettop(lua_state());
|
firstreturn = lua_gettop(lua_state());
|
||||||
return protected_function_result(lua_state(), firstreturn, 0, 1, call_status::runtime);
|
return protected_function_result(lua_state(), firstreturn, 0, 1, call_status::runtime);
|
||||||
}
|
}
|
||||||
#if SOL_IS_ON(SOL_EXCEPTIONS_CATCH_ALL_I_)
|
#if SOL_IS_ON(SOL_EXCEPTIONS_CATCH_ALL)
|
||||||
// LuaJIT cannot have the catchall when the safe propagation is on
|
// LuaJIT cannot have the catchall when the safe propagation is on
|
||||||
// but LuaJIT will swallow all C++ errors
|
// but LuaJIT will swallow all C++ errors
|
||||||
// if we don't at least catch std::exception ones
|
// if we don't at least catch std::exception ones
|
||||||
|
|
|
||||||
27
extern/sol3/sol/protected_function_result.hpp
vendored
27
extern/sol3/sol/protected_function_result.hpp
vendored
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
// The MIT License (MIT)
|
// The MIT License (MIT)
|
||||||
|
|
||||||
// Copyright (c) 2013-2021 Rapptz, ThePhD and contributors
|
// Copyright (c) 2013-2022 Rapptz, ThePhD and contributors
|
||||||
|
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
// this software and associated documentation files (the "Software"), to deal in
|
// this software and associated documentation files (the "Software"), to deal in
|
||||||
|
|
@ -54,9 +54,9 @@ namespace sol {
|
||||||
typedef std::reverse_iterator<iterator> reverse_iterator;
|
typedef std::reverse_iterator<iterator> reverse_iterator;
|
||||||
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
|
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
|
||||||
|
|
||||||
protected_function_result() noexcept = default;
|
protected_function_result() noexcept : protected_function_result(nullptr) {}
|
||||||
protected_function_result(lua_State* Ls, int idx = -1, int retnum = 0, int popped = 0, call_status pferr = call_status::ok) noexcept
|
protected_function_result(lua_State* Ls, int idx = -1, int retnum = 0, int popped = 0, call_status pferr = call_status::ok) noexcept
|
||||||
: L(Ls), index(idx), returncount(retnum), popcount(popped), err(pferr) {
|
: L( Ls), index(idx), returncount(retnum), popcount(popped), err(pferr) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// We do not want anyone to copy these around willy-nilly
|
// We do not want anyone to copy these around willy-nilly
|
||||||
|
|
@ -99,6 +99,13 @@ namespace sol {
|
||||||
return status() == call_status::ok || status() == call_status::yielded;
|
return status() == call_status::ok || status() == call_status::yielded;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if SOL_IS_ON(SOL_COMPILER_GCC)
|
||||||
|
#pragma GCC diagnostic push
|
||||||
|
#if !SOL_IS_ON(SOL_COMPILER_CLANG)
|
||||||
|
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
decltype(auto) get(int index_offset = 0) const {
|
decltype(auto) get(int index_offset = 0) const {
|
||||||
using UT = meta::unqualified_t<T>;
|
using UT = meta::unqualified_t<T>;
|
||||||
|
|
@ -109,7 +116,7 @@ namespace sol {
|
||||||
if (valid()) {
|
if (valid()) {
|
||||||
return UT();
|
return UT();
|
||||||
}
|
}
|
||||||
return UT(error(detail::direct_error, stack::get<std::string>(L, target)));
|
return UT(stack::stack_detail::get_error(L, target));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (!valid()) {
|
if (!valid()) {
|
||||||
|
|
@ -120,16 +127,16 @@ namespace sol {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if constexpr (std::is_same_v<T, error>) {
|
if constexpr (std::is_same_v<T, error>) {
|
||||||
#if SOL_IS_ON(SOL_SAFE_PROXIES_I_)
|
#if SOL_IS_ON(SOL_SAFE_PROXIES)
|
||||||
if (valid()) {
|
if (valid()) {
|
||||||
type t = type_of(L, target);
|
type t = type_of(L, target);
|
||||||
type_panic_c_str(L, target, t, type::none, "bad get from protected_function_result (is an error)");
|
type_panic_c_str(L, target, t, type::none, "bad get from protected_function_result (is an error)");
|
||||||
}
|
}
|
||||||
#endif // Check Argument Safety
|
#endif // Check Argument Safety
|
||||||
return error(detail::direct_error, stack::get<std::string>(L, target));
|
return stack::stack_detail::get_error(L, target);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
#if SOL_IS_ON(SOL_SAFE_PROXIES_I_)
|
#if SOL_IS_ON(SOL_SAFE_PROXIES)
|
||||||
if (!valid()) {
|
if (!valid()) {
|
||||||
type t = type_of(L, target);
|
type t = type_of(L, target);
|
||||||
type_panic_c_str(L, target, t, type::none, "bad get from protected_function_result (is not an error)");
|
type_panic_c_str(L, target, t, type::none, "bad get from protected_function_result (is not an error)");
|
||||||
|
|
@ -140,6 +147,10 @@ namespace sol {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if SOL_IS_ON(SOL_COMPILER_GCC)
|
||||||
|
#pragma GCC diagnostic pop
|
||||||
|
#endif
|
||||||
|
|
||||||
type get_type(int index_offset = 0) const noexcept {
|
type get_type(int index_offset = 0) const noexcept {
|
||||||
return type_of(L, index + static_cast<int>(index_offset));
|
return type_of(L, index + static_cast<int>(index_offset));
|
||||||
}
|
}
|
||||||
|
|
@ -216,7 +227,7 @@ namespace sol {
|
||||||
template <>
|
template <>
|
||||||
struct unqualified_pusher<protected_function_result> {
|
struct unqualified_pusher<protected_function_result> {
|
||||||
static int push(lua_State* L, const protected_function_result& pfr) {
|
static int push(lua_State* L, const protected_function_result& pfr) {
|
||||||
#if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_)
|
#if SOL_IS_ON(SOL_SAFE_STACK_CHECK)
|
||||||
luaL_checkstack(L, static_cast<int>(pfr.pop_count()), detail::not_enough_stack_space_generic);
|
luaL_checkstack(L, static_cast<int>(pfr.pop_count()), detail::not_enough_stack_space_generic);
|
||||||
#endif // make sure stack doesn't overflow
|
#endif // make sure stack doesn't overflow
|
||||||
int p = 0;
|
int p = 0;
|
||||||
|
|
|
||||||
4
extern/sol3/sol/protected_handler.hpp
vendored
4
extern/sol3/sol/protected_handler.hpp
vendored
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
// The MIT License (MIT)
|
// The MIT License (MIT)
|
||||||
|
|
||||||
// Copyright (c) 2013-2021 Rapptz, ThePhD and contributors
|
// Copyright (c) 2013-2022 Rapptz, ThePhD and contributors
|
||||||
|
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
// this software and associated documentation files (the "Software"), to deal in
|
// this software and associated documentation files (the "Software"), to deal in
|
||||||
|
|
@ -92,7 +92,7 @@ namespace sol { namespace detail {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!ref.valid()) {
|
if (!ref.valid()) {
|
||||||
#if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_)
|
#if SOL_IS_ON(SOL_SAFE_STACK_CHECK)
|
||||||
luaL_checkstack(L, 1, detail::not_enough_stack_space_generic);
|
luaL_checkstack(L, 1, detail::not_enough_stack_space_generic);
|
||||||
#endif // make sure stack doesn't overflow
|
#endif // make sure stack doesn't overflow
|
||||||
lua_pushnil(L);
|
lua_pushnil(L);
|
||||||
|
|
|
||||||
2
extern/sol3/sol/proxy_base.hpp
vendored
2
extern/sol3/sol/proxy_base.hpp
vendored
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
// The MIT License (MIT)
|
// The MIT License (MIT)
|
||||||
|
|
||||||
// Copyright (c) 2013-2021 Rapptz, ThePhD and contributors
|
// Copyright (c) 2013-2022 Rapptz, ThePhD and contributors
|
||||||
|
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
// this software and associated documentation files (the "Software"), to deal in
|
// this software and associated documentation files (the "Software"), to deal in
|
||||||
|
|
|
||||||
2
extern/sol3/sol/raii.hpp
vendored
2
extern/sol3/sol/raii.hpp
vendored
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
// The MIT License (MIT)
|
// The MIT License (MIT)
|
||||||
|
|
||||||
// Copyright (c) 2013-2021 Rapptz, ThePhD and contributors
|
// Copyright (c) 2013-2022 Rapptz, ThePhD and contributors
|
||||||
|
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
// this software and associated documentation files (the "Software"), to deal in
|
// this software and associated documentation files (the "Software"), to deal in
|
||||||
|
|
|
||||||
26
extern/sol3/sol/reference.hpp
vendored
26
extern/sol3/sol/reference.hpp
vendored
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
// The MIT License (MIT)
|
// The MIT License (MIT)
|
||||||
|
|
||||||
// Copyright (c) 2013-2021 Rapptz, ThePhD and contributors
|
// Copyright (c) 2013-2022 Rapptz, ThePhD and contributors
|
||||||
|
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
// this software and associated documentation files (the "Software"), to deal in
|
// this software and associated documentation files (the "Software"), to deal in
|
||||||
|
|
@ -289,7 +289,7 @@ namespace sol {
|
||||||
}
|
}
|
||||||
|
|
||||||
stateless_reference(lua_State* L_, global_tag_t) noexcept {
|
stateless_reference(lua_State* L_, global_tag_t) noexcept {
|
||||||
#if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_)
|
#if SOL_IS_ON(SOL_SAFE_STACK_CHECK)
|
||||||
luaL_checkstack(L_, 1, "not enough Lua stack space to push this reference value");
|
luaL_checkstack(L_, 1, "not enough Lua stack space to push this reference value");
|
||||||
#endif // make sure stack doesn't overflow
|
#endif // make sure stack doesn't overflow
|
||||||
lua_pushglobaltable(L_);
|
lua_pushglobaltable(L_);
|
||||||
|
|
@ -352,7 +352,7 @@ namespace sol {
|
||||||
}
|
}
|
||||||
|
|
||||||
stateless_reference(lua_State* L_, int index = -1) noexcept {
|
stateless_reference(lua_State* L_, int index = -1) noexcept {
|
||||||
#if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_)
|
#if SOL_IS_ON(SOL_SAFE_STACK_CHECK)
|
||||||
luaL_checkstack(L_, 1, "not enough Lua stack space to push this reference value");
|
luaL_checkstack(L_, 1, "not enough Lua stack space to push this reference value");
|
||||||
#endif // make sure stack doesn't overflow
|
#endif // make sure stack doesn't overflow
|
||||||
lua_pushvalue(L_, index);
|
lua_pushvalue(L_, index);
|
||||||
|
|
@ -383,7 +383,7 @@ namespace sol {
|
||||||
}
|
}
|
||||||
|
|
||||||
int push(lua_State* L_) const noexcept {
|
int push(lua_State* L_) const noexcept {
|
||||||
#if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_)
|
#if SOL_IS_ON(SOL_SAFE_STACK_CHECK)
|
||||||
luaL_checkstack(L_, 1, "not enough Lua stack space to push this reference value");
|
luaL_checkstack(L_, 1, "not enough Lua stack space to push this reference value");
|
||||||
#endif // make sure stack doesn't overflow
|
#endif // make sure stack doesn't overflow
|
||||||
lua_rawgeti(L_, LUA_REGISTRYINDEX, ref);
|
lua_rawgeti(L_, LUA_REGISTRYINDEX, ref);
|
||||||
|
|
@ -407,7 +407,7 @@ namespace sol {
|
||||||
|
|
||||||
void reset(lua_State* L_, int index_) noexcept {
|
void reset(lua_State* L_, int index_) noexcept {
|
||||||
reset(L_);
|
reset(L_);
|
||||||
#if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_)
|
#if SOL_IS_ON(SOL_SAFE_STACK_CHECK)
|
||||||
luaL_checkstack(L_, 1, "not enough Lua stack space to push this reference value");
|
luaL_checkstack(L_, 1, "not enough Lua stack space to push this reference value");
|
||||||
#endif // make sure stack doesn't overflow
|
#endif // make sure stack doesn't overflow
|
||||||
lua_pushvalue(L_, index_);
|
lua_pushvalue(L_, index_);
|
||||||
|
|
@ -616,7 +616,7 @@ namespace sol {
|
||||||
}
|
}
|
||||||
basic_reference(lua_State* L_, int index = -1) noexcept : luastate(detail::pick_main_thread<main_only>(L_, L_)) {
|
basic_reference(lua_State* L_, int index = -1) noexcept : luastate(detail::pick_main_thread<main_only>(L_, L_)) {
|
||||||
// use L_ to stick with that state's execution stack
|
// use L_ to stick with that state's execution stack
|
||||||
#if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_)
|
#if SOL_IS_ON(SOL_SAFE_STACK_CHECK)
|
||||||
luaL_checkstack(L_, 1, "not enough Lua stack space to push this reference value");
|
luaL_checkstack(L_, 1, "not enough Lua stack space to push this reference value");
|
||||||
#endif // make sure stack doesn't overflow
|
#endif // make sure stack doesn't overflow
|
||||||
lua_pushvalue(L_, index);
|
lua_pushvalue(L_, index);
|
||||||
|
|
@ -693,7 +693,7 @@ namespace sol {
|
||||||
}
|
}
|
||||||
|
|
||||||
int push(lua_State* L_) const noexcept {
|
int push(lua_State* L_) const noexcept {
|
||||||
#if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_)
|
#if SOL_IS_ON(SOL_SAFE_STACK_CHECK)
|
||||||
luaL_checkstack(L_, 1, "not enough Lua stack space to push this reference value");
|
luaL_checkstack(L_, 1, "not enough Lua stack space to push this reference value");
|
||||||
#endif // make sure stack doesn't overflow
|
#endif // make sure stack doesn't overflow
|
||||||
if (lua_state() == nullptr) {
|
if (lua_state() == nullptr) {
|
||||||
|
|
@ -828,6 +828,8 @@ namespace sol {
|
||||||
stateless_reference_equals(lua_State* L_) noexcept : stateless_stack_reference_equals(L_) {
|
stateless_reference_equals(lua_State* L_) noexcept : stateless_stack_reference_equals(L_) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
using stateless_stack_reference_equals::operator();
|
||||||
|
|
||||||
bool operator()(const lua_nil_t& lhs, const stateless_reference& rhs) const noexcept {
|
bool operator()(const lua_nil_t& lhs, const stateless_reference& rhs) const noexcept {
|
||||||
return rhs.equals(lua_state(), lhs);
|
return rhs.equals(lua_state(), lhs);
|
||||||
}
|
}
|
||||||
|
|
@ -839,6 +841,14 @@ namespace sol {
|
||||||
bool operator()(const stateless_reference& lhs, const stateless_reference& rhs) const noexcept {
|
bool operator()(const stateless_reference& lhs, const stateless_reference& rhs) const noexcept {
|
||||||
return lhs.equals(lua_state(), rhs);
|
return lhs.equals(lua_state(), rhs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool operator()(const stateless_stack_reference& lhs, const stateless_reference& rhs) const noexcept {
|
||||||
|
return rhs.equals(lua_state(), lhs);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator()(const stateless_reference& lhs, const stateless_stack_reference& rhs) const noexcept {
|
||||||
|
return lhs.equals(lua_state(), rhs);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct reference_equals : public stack_reference_equals {
|
struct reference_equals : public stack_reference_equals {
|
||||||
|
|
@ -878,6 +888,8 @@ namespace sol {
|
||||||
stateless_reference_hash(lua_State* L_) noexcept : stateless_stack_reference_hash(L_) {
|
stateless_reference_hash(lua_State* L_) noexcept : stateless_stack_reference_hash(L_) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
using stateless_stack_reference_hash::operator();
|
||||||
|
|
||||||
result_type operator()(const stateless_reference& lhs) const noexcept {
|
result_type operator()(const stateless_reference& lhs) const noexcept {
|
||||||
std::hash<const void*> h;
|
std::hash<const void*> h;
|
||||||
return h(lhs.pointer(lua_state()));
|
return h(lhs.pointer(lua_state()));
|
||||||
|
|
|
||||||
2
extern/sol3/sol/resolve.hpp
vendored
2
extern/sol3/sol/resolve.hpp
vendored
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
// The MIT License (MIT)
|
// The MIT License (MIT)
|
||||||
|
|
||||||
// Copyright (c) 2013-2021 Rapptz, ThePhD and contributors
|
// Copyright (c) 2013-2022 Rapptz, ThePhD and contributors
|
||||||
|
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
// this software and associated documentation files (the "Software"), to deal in
|
// this software and associated documentation files (the "Software"), to deal in
|
||||||
|
|
|
||||||
18
extern/sol3/sol/sol.hpp
vendored
18
extern/sol3/sol/sol.hpp
vendored
|
|
@ -1,6 +1,6 @@
|
||||||
// The MIT License (MIT)
|
// The MIT License (MIT)
|
||||||
|
|
||||||
// Copyright (c) 2013-2021 Rapptz, ThePhD and contributors
|
// Copyright (c) 2013-2022 Rapptz, ThePhD and contributors
|
||||||
|
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
// this software and associated documentation files (the "Software"), to deal in
|
// this software and associated documentation files (the "Software"), to deal in
|
||||||
|
|
@ -24,23 +24,23 @@
|
||||||
|
|
||||||
#include <sol/version.hpp>
|
#include <sol/version.hpp>
|
||||||
|
|
||||||
#if SOL_IS_ON(SOL_INSIDE_UNREAL_ENGINE_I_)
|
#if SOL_IS_ON(SOL_INSIDE_UNREAL_ENGINE)
|
||||||
#ifdef check
|
#ifdef check
|
||||||
#pragma push_macro("check")
|
#pragma push_macro("check")
|
||||||
#undef check
|
#undef check
|
||||||
#endif
|
#endif
|
||||||
#endif // Unreal Engine 4 Bullshit
|
#endif // Unreal Engine 4 Bullshit
|
||||||
|
|
||||||
#if SOL_IS_ON(SOL_COMPILER_GCC_I_)
|
#if SOL_IS_ON(SOL_COMPILER_GCC)
|
||||||
#pragma GCC diagnostic push
|
#pragma GCC diagnostic push
|
||||||
#pragma GCC diagnostic ignored "-Wshadow"
|
#pragma GCC diagnostic ignored "-Wshadow"
|
||||||
#pragma GCC diagnostic ignored "-Wconversion"
|
#pragma GCC diagnostic ignored "-Wconversion"
|
||||||
#if __GNUC__ > 6
|
#if __GNUC__ > 6
|
||||||
#pragma GCC diagnostic ignored "-Wnoexcept-type"
|
#pragma GCC diagnostic ignored "-Wnoexcept-type"
|
||||||
#endif
|
#endif
|
||||||
#elif SOL_IS_ON(SOL_COMPILER_CLANG_I_)
|
#elif SOL_IS_ON(SOL_COMPILER_CLANG)
|
||||||
// we'll just let this alone for now
|
// we'll just let this alone for now
|
||||||
#elif SOL_IS_ON(SOL_COMPILER_VCXX_I_)
|
#elif SOL_IS_ON(SOL_COMPILER_VCXX)
|
||||||
#pragma warning(push)
|
#pragma warning(push)
|
||||||
#pragma warning(disable : 4505) // unreferenced local function has been removed GEE THANKS
|
#pragma warning(disable : 4505) // unreferenced local function has been removed GEE THANKS
|
||||||
#endif // clang++ vs. g++ vs. VC++
|
#endif // clang++ vs. g++ vs. VC++
|
||||||
|
|
@ -65,13 +65,15 @@
|
||||||
#include <sol/variadic_results.hpp>
|
#include <sol/variadic_results.hpp>
|
||||||
#include <sol/lua_value.hpp>
|
#include <sol/lua_value.hpp>
|
||||||
|
|
||||||
#if SOL_IS_ON(SOL_COMPILER_GCC_I_)
|
#if SOL_IS_ON(SOL_COMPILER_GCC)
|
||||||
#pragma GCC diagnostic pop
|
#pragma GCC diagnostic pop
|
||||||
#elif SOL_IS_ON(SOL_COMPILER_VCXX_I_)
|
#elif SOL_IS_ON(SOL_COMPILER_CLANG)
|
||||||
|
// we'll just let this alone for now
|
||||||
|
#elif SOL_IS_ON(SOL_COMPILER_VCXX)
|
||||||
#pragma warning(pop)
|
#pragma warning(pop)
|
||||||
#endif // g++
|
#endif // g++
|
||||||
|
|
||||||
#if SOL_IS_ON(SOL_INSIDE_UNREAL_ENGINE_I_)
|
#if SOL_IS_ON(SOL_INSIDE_UNREAL_ENGINE)
|
||||||
#undef check
|
#undef check
|
||||||
#pragma pop_macro("check")
|
#pragma pop_macro("check")
|
||||||
#endif // Unreal Engine 4 Bullshit
|
#endif // Unreal Engine 4 Bullshit
|
||||||
|
|
|
||||||
735
extern/sol3/sol/stack.hpp
vendored
735
extern/sol3/sol/stack.hpp
vendored
|
|
@ -1,351 +1,384 @@
|
||||||
// sol2
|
// sol2
|
||||||
|
|
||||||
// The MIT License (MIT)
|
// The MIT License (MIT)
|
||||||
|
|
||||||
// Copyright (c) 2013-2021 Rapptz, ThePhD and contributors
|
// Copyright (c) 2013-2022 Rapptz, ThePhD and contributors
|
||||||
|
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
// this software and associated documentation files (the "Software"), to deal in
|
// this software and associated documentation files (the "Software"), to deal in
|
||||||
// the Software without restriction, including without limitation the rights to
|
// the Software without restriction, including without limitation the rights to
|
||||||
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||||
// the Software, and to permit persons to whom the Software is furnished to do so,
|
// the Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
// subject to the following conditions:
|
// subject to the following conditions:
|
||||||
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
// The above copyright notice and this permission notice shall be included in all
|
||||||
// copies or substantial portions of the Software.
|
// copies or substantial portions of the Software.
|
||||||
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
#ifndef SOL_STACK_HPP
|
#ifndef SOL_STACK_HPP
|
||||||
#define SOL_STACK_HPP
|
#define SOL_STACK_HPP
|
||||||
|
|
||||||
#include <sol/trampoline.hpp>
|
#include <sol/trampoline.hpp>
|
||||||
#include <sol/stack_core.hpp>
|
#include <sol/stack_core.hpp>
|
||||||
#include <sol/stack_reference.hpp>
|
#include <sol/stack_reference.hpp>
|
||||||
#include <sol/stack_check.hpp>
|
#include <sol/stack_check.hpp>
|
||||||
#include <sol/stack_get.hpp>
|
#include <sol/stack_get.hpp>
|
||||||
#include <sol/stack_check_get.hpp>
|
#include <sol/stack_check_get.hpp>
|
||||||
#include <sol/stack_push.hpp>
|
#include <sol/stack_push.hpp>
|
||||||
#include <sol/stack_pop.hpp>
|
#include <sol/stack_pop.hpp>
|
||||||
#include <sol/stack_field.hpp>
|
#include <sol/stack_field.hpp>
|
||||||
#include <sol/stack_probe.hpp>
|
#include <sol/stack_probe.hpp>
|
||||||
|
#include <sol/error.hpp>
|
||||||
#include <cstring>
|
#include <sol/assert.hpp>
|
||||||
#include <array>
|
|
||||||
|
#include <cstring>
|
||||||
namespace sol {
|
#include <array>
|
||||||
namespace detail {
|
|
||||||
using typical_chunk_name_t = char[SOL_ID_SIZE_I_];
|
namespace sol {
|
||||||
using typical_file_chunk_name_t = char[SOL_FILE_ID_SIZE_I_];
|
namespace detail {
|
||||||
|
using typical_chunk_name_t = char[SOL_ID_SIZE_I_];
|
||||||
inline const std::string& default_chunk_name() {
|
using typical_file_chunk_name_t = char[SOL_FILE_ID_SIZE_I_];
|
||||||
static const std::string name = "";
|
|
||||||
return name;
|
inline const std::string& default_chunk_name() {
|
||||||
}
|
static const std::string name = "";
|
||||||
|
return name;
|
||||||
template <std::size_t N>
|
}
|
||||||
const char* make_chunk_name(const string_view& code, const std::string& chunkname, char (&basechunkname)[N]) {
|
|
||||||
if (chunkname.empty()) {
|
template <std::size_t N>
|
||||||
auto it = code.cbegin();
|
const char* make_chunk_name(const string_view& code, const std::string& chunkname, char (&basechunkname)[N]) {
|
||||||
auto e = code.cend();
|
if (chunkname.empty()) {
|
||||||
std::size_t i = 0;
|
auto it = code.cbegin();
|
||||||
static const std::size_t n = N - 4;
|
auto e = code.cend();
|
||||||
for (i = 0; i < n && it != e; ++i, ++it) {
|
std::size_t i = 0;
|
||||||
basechunkname[i] = *it;
|
static const std::size_t n = N - 4;
|
||||||
}
|
for (i = 0; i < n && it != e; ++i, ++it) {
|
||||||
if (it != e) {
|
basechunkname[i] = *it;
|
||||||
for (std::size_t c = 0; c < 3; ++i, ++c) {
|
}
|
||||||
basechunkname[i] = '.';
|
if (it != e) {
|
||||||
}
|
for (std::size_t c = 0; c < 3; ++i, ++c) {
|
||||||
}
|
basechunkname[i] = '.';
|
||||||
basechunkname[i] = '\0';
|
}
|
||||||
return &basechunkname[0];
|
}
|
||||||
}
|
basechunkname[i] = '\0';
|
||||||
else {
|
return &basechunkname[0];
|
||||||
return chunkname.c_str();
|
}
|
||||||
}
|
else {
|
||||||
}
|
return chunkname.c_str();
|
||||||
|
}
|
||||||
inline void clear_entries(stack_reference r) {
|
}
|
||||||
stack::push(r.lua_state(), lua_nil);
|
|
||||||
while (lua_next(r.lua_state(), -2)) {
|
inline void clear_entries(stack_reference r) {
|
||||||
absolute_index key(r.lua_state(), -2);
|
stack::push(r.lua_state(), lua_nil);
|
||||||
auto pn = stack::pop_n(r.lua_state(), 1);
|
while (lua_next(r.lua_state(), -2)) {
|
||||||
stack::set_field<false, true>(r.lua_state(), key, lua_nil, r.stack_index());
|
absolute_index key(r.lua_state(), -2);
|
||||||
}
|
auto pn = stack::pop_n(r.lua_state(), 1);
|
||||||
}
|
stack::set_field<false, true>(r.lua_state(), key, lua_nil, r.stack_index());
|
||||||
|
}
|
||||||
inline void clear_entries(const reference& registry_reference) {
|
}
|
||||||
auto pp = stack::push_pop(registry_reference);
|
|
||||||
stack_reference ref(registry_reference.lua_state(), -1);
|
inline void clear_entries(const reference& registry_reference) {
|
||||||
clear_entries(ref);
|
auto pp = stack::push_pop(registry_reference);
|
||||||
}
|
stack_reference ref(registry_reference.lua_state(), -1);
|
||||||
} // namespace detail
|
clear_entries(ref);
|
||||||
|
}
|
||||||
namespace stack {
|
} // namespace detail
|
||||||
namespace stack_detail {
|
|
||||||
template <typename T>
|
namespace stack {
|
||||||
inline int push_as_upvalues(lua_State* L, T& item) {
|
namespace stack_detail {
|
||||||
typedef std::decay_t<T> TValue;
|
template <typename T>
|
||||||
static const std::size_t itemsize = sizeof(TValue);
|
inline int push_as_upvalues(lua_State* L, T& item) {
|
||||||
static const std::size_t voidsize = sizeof(void*);
|
typedef std::decay_t<T> TValue;
|
||||||
static const std::size_t voidsizem1 = voidsize - 1;
|
static const std::size_t itemsize = sizeof(TValue);
|
||||||
static const std::size_t data_t_count = (sizeof(TValue) + voidsizem1) / voidsize;
|
static const std::size_t voidsize = sizeof(void*);
|
||||||
typedef std::array<void*, data_t_count> data_t;
|
static const std::size_t voidsizem1 = voidsize - 1;
|
||||||
|
static const std::size_t data_t_count = (sizeof(TValue) + voidsizem1) / voidsize;
|
||||||
data_t data { {} };
|
typedef std::array<void*, data_t_count> data_t;
|
||||||
std::memcpy(&data[0], std::addressof(item), itemsize);
|
|
||||||
int pushcount = 0;
|
data_t data { {} };
|
||||||
for (const auto& v : data) {
|
std::memcpy(&data[0], std::addressof(item), itemsize);
|
||||||
lua_pushlightuserdata(L, v);
|
int pushcount = 0;
|
||||||
pushcount += 1;
|
for (const auto& v : data) {
|
||||||
}
|
lua_pushlightuserdata(L, v);
|
||||||
return pushcount;
|
pushcount += 1;
|
||||||
}
|
}
|
||||||
|
return pushcount;
|
||||||
template <typename T>
|
}
|
||||||
inline std::pair<T, int> get_as_upvalues(lua_State* L, int index = 2) {
|
|
||||||
static const std::size_t data_t_count = (sizeof(T) + (sizeof(void*) - 1)) / sizeof(void*);
|
template <typename T>
|
||||||
typedef std::array<void*, data_t_count> data_t;
|
inline std::pair<T, int> get_as_upvalues(lua_State* L, int index = 2) {
|
||||||
data_t voiddata { {} };
|
static const std::size_t data_t_count = (sizeof(T) + (sizeof(void*) - 1)) / sizeof(void*);
|
||||||
for (std::size_t i = 0, d = 0; d < sizeof(T); ++i, d += sizeof(void*)) {
|
typedef std::array<void*, data_t_count> data_t;
|
||||||
voiddata[i] = lua_touserdata(L, upvalue_index(index++));
|
data_t voiddata { {} };
|
||||||
}
|
for (std::size_t i = 0, d = 0; d < sizeof(T); ++i, d += sizeof(void*)) {
|
||||||
return std::pair<T, int>(*reinterpret_cast<T*>(static_cast<void*>(voiddata.data())), index);
|
voiddata[i] = lua_touserdata(L, upvalue_index(index++));
|
||||||
}
|
}
|
||||||
|
return std::pair<T, int>(*reinterpret_cast<T*>(static_cast<void*>(voiddata.data())), index);
|
||||||
template <typename T>
|
}
|
||||||
inline std::pair<T, int> get_as_upvalues_using_function(lua_State* L, int function_index = -1) {
|
|
||||||
static const std::size_t data_t_count = (sizeof(T) + (sizeof(void*) - 1)) / sizeof(void*);
|
template <typename T>
|
||||||
typedef std::array<void*, data_t_count> data_t;
|
inline std::pair<T, int> get_as_upvalues_using_function(lua_State* L, int function_index = -1) {
|
||||||
function_index = lua_absindex(L, function_index);
|
static const std::size_t data_t_count = (sizeof(T) + (sizeof(void*) - 1)) / sizeof(void*);
|
||||||
int index = 0;
|
typedef std::array<void*, data_t_count> data_t;
|
||||||
data_t voiddata { {} };
|
function_index = lua_absindex(L, function_index);
|
||||||
for (std::size_t d = 0; d < sizeof(T); d += sizeof(void*)) {
|
int index = 0;
|
||||||
// first upvalue is nullptr to respect environment shenanigans
|
data_t voiddata { {} };
|
||||||
// So +2 instead of +1
|
for (std::size_t d = 0; d < sizeof(T); d += sizeof(void*)) {
|
||||||
const char* upvalue_name = lua_getupvalue(L, function_index, index + 2);
|
// first upvalue is nullptr to respect environment shenanigans
|
||||||
if (upvalue_name == nullptr) {
|
// So +2 instead of +1
|
||||||
// We should freak out here...
|
const char* upvalue_name = lua_getupvalue(L, function_index, index + 2);
|
||||||
break;
|
if (upvalue_name == nullptr) {
|
||||||
}
|
// We should freak out here...
|
||||||
voiddata[index] = lua_touserdata(L, -1);
|
break;
|
||||||
++index;
|
}
|
||||||
}
|
voiddata[index] = lua_touserdata(L, -1);
|
||||||
lua_pop(L, index);
|
++index;
|
||||||
return std::pair<T, int>(*reinterpret_cast<T*>(static_cast<void*>(voiddata.data())), index);
|
}
|
||||||
}
|
lua_pop(L, index);
|
||||||
|
return std::pair<T, int>(*reinterpret_cast<T*>(static_cast<void*>(voiddata.data())), index);
|
||||||
template <bool checked, typename Handler, typename Fx, typename... Args>
|
}
|
||||||
static decltype(auto) eval(types<>, std::index_sequence<>, lua_State*, int, Handler&&, record&, Fx&& fx, Args&&... args) {
|
|
||||||
return std::forward<Fx>(fx)(std::forward<Args>(args)...);
|
template <bool checked, typename Handler, typename Fx, typename... Args>
|
||||||
}
|
static decltype(auto) eval(types<>, std::index_sequence<>, lua_State*, int, Handler&&, record&, Fx&& fx, Args&&... args) {
|
||||||
|
return std::forward<Fx>(fx)(std::forward<Args>(args)...);
|
||||||
template <bool checked, typename Arg, typename... Args, std::size_t I, std::size_t... Is, typename Handler, typename Fx, typename... FxArgs>
|
}
|
||||||
static decltype(auto) eval(types<Arg, Args...>, std::index_sequence<I, Is...>, lua_State* L_, int start_index_, Handler&& handler_,
|
|
||||||
record& tracking_, Fx&& fx_, FxArgs&&... fxargs_) {
|
template <bool checked, typename Arg, typename... Args, std::size_t I, std::size_t... Is, typename Handler, typename Fx, typename... FxArgs>
|
||||||
#if SOL_IS_ON(SOL_PROPAGATE_EXCEPTIONS_I_)
|
static decltype(auto) eval(types<Arg, Args...>, std::index_sequence<I, Is...>, lua_State* L_, int start_index_, Handler&& handler_,
|
||||||
// We can save performance/time by letting errors unwind produced arguments
|
record& tracking_, Fx&& fx_, FxArgs&&... fxargs_) {
|
||||||
// rather than checking everything once, and then potentially re-doing work
|
#if 0 && SOL_IS_ON(SOL_PROPAGATE_EXCEPTIONS)
|
||||||
if constexpr (checked) {
|
// NOTE: THIS IS TERMPORARILY TURNED OFF BECAUSE IT IMPACTS ACTUAL SEMANTICS W.R.T. THINGS LIKE LUAJIT,
|
||||||
return eval<checked>(types<Args...>(),
|
// SO IT MUST REMAIN OFF UNTIL WE CAN ESTABLISH SIMILAR BEHAVIOR IN MODES WHERE `checked == false`!
|
||||||
std::index_sequence<Is...>(),
|
|
||||||
L_,
|
// We can save performance/time by letting errors unwind produced arguments
|
||||||
start_index_,
|
// rather than checking everything once, and then potentially re-doing work
|
||||||
std::forward<Handler>(handler_),
|
if constexpr (checked) {
|
||||||
tracking_,
|
return eval<checked>(types<Args...>(),
|
||||||
std::forward<Fx>(fx_),
|
std::index_sequence<Is...>(),
|
||||||
std::forward<FxArgs>(fxargs_)...,
|
L_,
|
||||||
*stack_detail::check_get_arg<Arg>(L_, start_index_ + tracking_.used, handler_, tracking_));
|
start_index_,
|
||||||
}
|
std::forward<Handler>(handler_),
|
||||||
else
|
tracking_,
|
||||||
#endif
|
std::forward<Fx>(fx_),
|
||||||
{
|
std::forward<FxArgs>(fxargs_)...,
|
||||||
return eval<checked>(types<Args...>(),
|
*stack_detail::check_get_arg<Arg>(L_, start_index_ + tracking_.used, handler_, tracking_));
|
||||||
std::index_sequence<Is...>(),
|
}
|
||||||
L_,
|
else
|
||||||
start_index_,
|
#endif
|
||||||
std::forward<Handler>(handler_),
|
{
|
||||||
tracking_,
|
return eval<checked>(types<Args...>(),
|
||||||
std::forward<Fx>(fx_),
|
std::index_sequence<Is...>(),
|
||||||
std::forward<FxArgs>(fxargs_)...,
|
L_,
|
||||||
stack_detail::unchecked_get_arg<Arg>(L_, start_index_ + tracking_.used, tracking_));
|
start_index_,
|
||||||
}
|
std::forward<Handler>(handler_),
|
||||||
}
|
tracking_,
|
||||||
|
std::forward<Fx>(fx_),
|
||||||
template <bool checkargs = detail::default_safe_function_calls, std::size_t... I, typename R, typename... Args, typename Fx, typename... FxArgs>
|
std::forward<FxArgs>(fxargs_)...,
|
||||||
inline decltype(auto) call(types<R>, types<Args...> argument_types_, std::index_sequence<I...> argument_indices_, lua_State* L_,
|
stack_detail::unchecked_get_arg<Arg>(L_, start_index_ + tracking_.used, tracking_));
|
||||||
int start_index_, Fx&& fx_, FxArgs&&... args_) {
|
}
|
||||||
static_assert(meta::all_v<meta::is_not_move_only<Args>...>,
|
}
|
||||||
"One of the arguments being bound is a move-only type, and it is not being taken by reference: this will break your code. Please take "
|
|
||||||
"a reference and std::move it manually if this was your intention.");
|
template <bool checkargs = detail::default_safe_function_calls, std::size_t... I, typename R, typename... Args, typename Fx, typename... FxArgs>
|
||||||
argument_handler<types<R, Args...>> handler {};
|
inline decltype(auto) call(types<R>, types<Args...> argument_types_, std::index_sequence<I...> argument_indices_, lua_State* L_,
|
||||||
record tracking {};
|
int start_index_, Fx&& fx_, FxArgs&&... args_) {
|
||||||
#if SOL_IS_OFF(SOL_PROPAGATE_EXCEPTIONS_I_)
|
static_assert(meta::all_v<meta::is_not_move_only<Args>...>,
|
||||||
if constexpr (checkargs) {
|
"One of the arguments being bound is a move-only type, and it is not being taken by reference: this will break your code. Please take "
|
||||||
multi_check<Args...>(L_, start_index_, handler);
|
"a reference and std::move it manually if this was your intention.");
|
||||||
}
|
argument_handler<types<R, Args...>> handler {};
|
||||||
#endif
|
record tracking {};
|
||||||
if constexpr (std::is_void_v<R>) {
|
#if SOL_IS_OFF(SOL_PROPAGATE_EXCEPTIONS)
|
||||||
eval<checkargs>(
|
if constexpr (checkargs) {
|
||||||
argument_types_, argument_indices_, L_, start_index_, handler, tracking, std::forward<Fx>(fx_), std::forward<FxArgs>(args_)...);
|
multi_check<Args...>(L_, start_index_, handler);
|
||||||
}
|
}
|
||||||
else {
|
#endif
|
||||||
return eval<checkargs>(
|
if constexpr (std::is_void_v<R>) {
|
||||||
argument_types_, argument_indices_, L_, start_index_, handler, tracking, std::forward<Fx>(fx_), std::forward<FxArgs>(args_)...);
|
eval<checkargs>(
|
||||||
}
|
argument_types_, argument_indices_, L_, start_index_, handler, tracking, std::forward<Fx>(fx_), std::forward<FxArgs>(args_)...);
|
||||||
}
|
}
|
||||||
} // namespace stack_detail
|
else {
|
||||||
|
return eval<checkargs>(
|
||||||
template <typename T>
|
argument_types_, argument_indices_, L_, start_index_, handler, tracking, std::forward<Fx>(fx_), std::forward<FxArgs>(args_)...);
|
||||||
int set_ref(lua_State* L, T&& arg, int tableindex = -2) {
|
}
|
||||||
push(L, std::forward<T>(arg));
|
}
|
||||||
return luaL_ref(L, tableindex);
|
|
||||||
}
|
template <typename T>
|
||||||
|
void raw_table_set(lua_State* L, T&& arg, int tableindex = -2) {
|
||||||
template <bool check_args = detail::default_safe_function_calls, typename R, typename... Args, typename Fx, typename... FxArgs>
|
int push_count = push(L, std::forward<T>(arg));
|
||||||
inline decltype(auto) call(types<R> tr, types<Args...> ta, lua_State* L, int start, Fx&& fx, FxArgs&&... args) {
|
SOL_ASSERT(push_count == 1);
|
||||||
using args_indices = std::make_index_sequence<sizeof...(Args)>;
|
std::size_t unique_index = static_cast<std::size_t>(luaL_len(L, tableindex) + 1u);
|
||||||
if constexpr (std::is_void_v<R>) {
|
lua_rawseti(L, tableindex, static_cast<int>(unique_index));
|
||||||
stack_detail::call<check_args>(tr, ta, args_indices(), L, start, std::forward<Fx>(fx), std::forward<FxArgs>(args)...);
|
}
|
||||||
}
|
|
||||||
else {
|
} // namespace stack_detail
|
||||||
return stack_detail::call<check_args>(tr, ta, args_indices(), L, start, std::forward<Fx>(fx), std::forward<FxArgs>(args)...);
|
|
||||||
}
|
template <typename T>
|
||||||
}
|
int set_ref(lua_State* L, T&& arg, int tableindex = -2) {
|
||||||
|
int push_count = push(L, std::forward<T>(arg));
|
||||||
template <bool check_args = detail::default_safe_function_calls, typename R, typename... Args, typename Fx, typename... FxArgs>
|
SOL_ASSERT(push_count == 1);
|
||||||
inline decltype(auto) call(types<R> tr, types<Args...> ta, lua_State* L, Fx&& fx, FxArgs&&... args) {
|
return luaL_ref(L, tableindex);
|
||||||
if constexpr (std::is_void_v<R>) {
|
}
|
||||||
call<check_args>(tr, ta, L, 1, std::forward<Fx>(fx), std::forward<FxArgs>(args)...);
|
|
||||||
}
|
template <bool check_args = detail::default_safe_function_calls, typename R, typename... Args, typename Fx, typename... FxArgs>
|
||||||
else {
|
inline decltype(auto) call(types<R> tr, types<Args...> ta, lua_State* L, int start, Fx&& fx, FxArgs&&... args) {
|
||||||
return call<check_args>(tr, ta, L, 1, std::forward<Fx>(fx), std::forward<FxArgs>(args)...);
|
using args_indices = std::make_index_sequence<sizeof...(Args)>;
|
||||||
}
|
if constexpr (std::is_void_v<R>) {
|
||||||
}
|
stack_detail::call<check_args>(tr, ta, args_indices(), L, start, std::forward<Fx>(fx), std::forward<FxArgs>(args)...);
|
||||||
|
}
|
||||||
template <bool check_args = detail::default_safe_function_calls, typename R, typename... Args, typename Fx, typename... FxArgs>
|
else {
|
||||||
inline decltype(auto) call_from_top(types<R> tr, types<Args...> ta, lua_State* L, Fx&& fx, FxArgs&&... args) {
|
return stack_detail::call<check_args>(tr, ta, args_indices(), L, start, std::forward<Fx>(fx), std::forward<FxArgs>(args)...);
|
||||||
using expected_count_t = meta::count_for_pack<lua_size, Args...>;
|
}
|
||||||
if constexpr (std::is_void_v<R>) {
|
}
|
||||||
call<check_args>(tr,
|
|
||||||
ta,
|
template <bool check_args = detail::default_safe_function_calls, typename R, typename... Args, typename Fx, typename... FxArgs>
|
||||||
L,
|
inline decltype(auto) call(types<R> tr, types<Args...> ta, lua_State* L, Fx&& fx, FxArgs&&... args) {
|
||||||
(std::max)(static_cast<int>(lua_gettop(L) - expected_count_t::value), static_cast<int>(0)),
|
if constexpr (std::is_void_v<R>) {
|
||||||
std::forward<Fx>(fx),
|
call<check_args>(tr, ta, L, 1, std::forward<Fx>(fx), std::forward<FxArgs>(args)...);
|
||||||
std::forward<FxArgs>(args)...);
|
}
|
||||||
}
|
else {
|
||||||
else {
|
return call<check_args>(tr, ta, L, 1, std::forward<Fx>(fx), std::forward<FxArgs>(args)...);
|
||||||
return call<check_args>(tr,
|
}
|
||||||
ta,
|
}
|
||||||
L,
|
|
||||||
(std::max)(static_cast<int>(lua_gettop(L) - expected_count_t::value), static_cast<int>(0)),
|
template <bool check_args = detail::default_safe_function_calls, typename R, typename... Args, typename Fx, typename... FxArgs>
|
||||||
std::forward<Fx>(fx),
|
inline decltype(auto) call_from_top(types<R> tr, types<Args...> ta, lua_State* L, Fx&& fx, FxArgs&&... args) {
|
||||||
std::forward<FxArgs>(args)...);
|
using expected_count_t = meta::count_for_pack<lua_size, Args...>;
|
||||||
}
|
if constexpr (std::is_void_v<R>) {
|
||||||
}
|
call<check_args>(tr,
|
||||||
|
ta,
|
||||||
template <bool check_args = detail::default_safe_function_calls, bool clean_stack = true, typename Ret0, typename... Ret, typename... Args,
|
L,
|
||||||
typename Fx, typename... FxArgs>
|
(std::max)(static_cast<int>(lua_gettop(L) - expected_count_t::value), static_cast<int>(0)),
|
||||||
inline int call_into_lua(types<Ret0, Ret...> tr, types<Args...> ta, lua_State* L, int start, Fx&& fx, FxArgs&&... fxargs) {
|
std::forward<Fx>(fx),
|
||||||
if constexpr (std::is_void_v<Ret0>) {
|
std::forward<FxArgs>(args)...);
|
||||||
call<check_args>(tr, ta, L, start, std::forward<Fx>(fx), std::forward<FxArgs>(fxargs)...);
|
}
|
||||||
if constexpr (clean_stack) {
|
else {
|
||||||
lua_settop(L, 0);
|
return call<check_args>(tr,
|
||||||
}
|
ta,
|
||||||
return 0;
|
L,
|
||||||
}
|
(std::max)(static_cast<int>(lua_gettop(L) - expected_count_t::value), static_cast<int>(0)),
|
||||||
else {
|
std::forward<Fx>(fx),
|
||||||
(void)tr;
|
std::forward<FxArgs>(args)...);
|
||||||
decltype(auto) r
|
}
|
||||||
= call<check_args>(types<meta::return_type_t<Ret0, Ret...>>(), ta, L, start, std::forward<Fx>(fx), std::forward<FxArgs>(fxargs)...);
|
}
|
||||||
using R = meta::unqualified_t<decltype(r)>;
|
|
||||||
using is_stack = meta::any<is_stack_based<R>, std::is_same<R, absolute_index>, std::is_same<R, ref_index>, std::is_same<R, raw_index>>;
|
template <bool check_args = detail::default_safe_function_calls, bool clean_stack = true, typename Ret0, typename... Ret, typename... Args,
|
||||||
if constexpr (clean_stack && !is_stack::value) {
|
typename Fx, typename... FxArgs>
|
||||||
lua_settop(L, 0);
|
inline int call_into_lua(types<Ret0, Ret...> tr, types<Args...> ta, lua_State* L, int start, Fx&& fx, FxArgs&&... fxargs) {
|
||||||
}
|
if constexpr (std::is_void_v<Ret0>) {
|
||||||
return push_reference(L, std::forward<decltype(r)>(r));
|
call<check_args>(tr, ta, L, start, std::forward<Fx>(fx), std::forward<FxArgs>(fxargs)...);
|
||||||
}
|
if constexpr (clean_stack) {
|
||||||
}
|
lua_settop(L, 0);
|
||||||
|
}
|
||||||
template <bool check_args = detail::default_safe_function_calls, bool clean_stack = true, typename Fx, typename... FxArgs>
|
return 0;
|
||||||
inline int call_lua(lua_State* L, int start, Fx&& fx, FxArgs&&... fxargs) {
|
}
|
||||||
using traits_type = lua_bind_traits<meta::unqualified_t<Fx>>;
|
else {
|
||||||
using args_list = typename traits_type::args_list;
|
(void)tr;
|
||||||
using returns_list = typename traits_type::returns_list;
|
decltype(auto) r
|
||||||
return call_into_lua<check_args, clean_stack>(returns_list(), args_list(), L, start, std::forward<Fx>(fx), std::forward<FxArgs>(fxargs)...);
|
= call<check_args>(types<meta::return_type_t<Ret0, Ret...>>(), ta, L, start, std::forward<Fx>(fx), std::forward<FxArgs>(fxargs)...);
|
||||||
}
|
using R = meta::unqualified_t<decltype(r)>;
|
||||||
|
using is_stack = meta::any<is_stack_based<R>, std::is_same<R, absolute_index>, std::is_same<R, ref_index>, std::is_same<R, raw_index>>;
|
||||||
inline call_syntax get_call_syntax(lua_State* L, const string_view& key, int index) {
|
if constexpr (clean_stack && !is_stack::value) {
|
||||||
if (lua_gettop(L) < 1) {
|
lua_settop(L, 0);
|
||||||
return call_syntax::dot;
|
}
|
||||||
}
|
return push_reference(L, std::forward<decltype(r)>(r));
|
||||||
luaL_getmetatable(L, key.data());
|
}
|
||||||
auto pn = pop_n(L, 1);
|
}
|
||||||
if (lua_compare(L, -1, index, LUA_OPEQ) != 1) {
|
|
||||||
return call_syntax::dot;
|
template <bool check_args = detail::default_safe_function_calls, bool clean_stack = true, typename Fx, typename... FxArgs>
|
||||||
}
|
inline int call_lua(lua_State* L, int start, Fx&& fx, FxArgs&&... fxargs) {
|
||||||
return call_syntax::colon;
|
using traits_type = lua_bind_traits<meta::unqualified_t<Fx>>;
|
||||||
}
|
using args_list = typename traits_type::args_list;
|
||||||
|
using returns_list = typename traits_type::returns_list;
|
||||||
inline void script(
|
return call_into_lua<check_args, clean_stack>(returns_list(), args_list(), L, start, std::forward<Fx>(fx), std::forward<FxArgs>(fxargs)...);
|
||||||
lua_State* L, lua_Reader reader, void* data, const std::string& chunkname = detail::default_chunk_name(), load_mode mode = load_mode::any) {
|
}
|
||||||
detail::typical_chunk_name_t basechunkname = {};
|
|
||||||
const char* chunknametarget = detail::make_chunk_name("lua_Reader", chunkname, basechunkname);
|
inline call_syntax get_call_syntax(lua_State* L, const string_view& key, int index) {
|
||||||
if (lua_load(L, reader, data, chunknametarget, to_string(mode).c_str()) || lua_pcall(L, 0, LUA_MULTRET, 0)) {
|
if (lua_gettop(L) < 1) {
|
||||||
lua_error(L);
|
return call_syntax::dot;
|
||||||
}
|
}
|
||||||
}
|
luaL_getmetatable(L, key.data());
|
||||||
|
auto pn = pop_n(L, 1);
|
||||||
inline void script(
|
if (lua_compare(L, -1, index, LUA_OPEQ) != 1) {
|
||||||
lua_State* L, const string_view& code, const std::string& chunkname = detail::default_chunk_name(), load_mode mode = load_mode::any) {
|
return call_syntax::dot;
|
||||||
|
}
|
||||||
detail::typical_chunk_name_t basechunkname = {};
|
return call_syntax::colon;
|
||||||
const char* chunknametarget = detail::make_chunk_name(code, chunkname, basechunkname);
|
}
|
||||||
if (luaL_loadbufferx(L, code.data(), code.size(), chunknametarget, to_string(mode).c_str()) || lua_pcall(L, 0, LUA_MULTRET, 0)) {
|
|
||||||
lua_error(L);
|
inline void script(
|
||||||
}
|
lua_State* L, lua_Reader reader, void* data, const std::string& chunkname = detail::default_chunk_name(), load_mode mode = load_mode::any) {
|
||||||
}
|
detail::typical_chunk_name_t basechunkname = {};
|
||||||
|
const char* chunknametarget = detail::make_chunk_name("lua_Reader", chunkname, basechunkname);
|
||||||
inline void script_file(lua_State* L, const std::string& filename, load_mode mode = load_mode::any) {
|
if (lua_load(L, reader, data, chunknametarget, to_string(mode).c_str()) || lua_pcall(L, 0, LUA_MULTRET, 0)) {
|
||||||
if (luaL_loadfilex(L, filename.c_str(), to_string(mode).c_str()) || lua_pcall(L, 0, LUA_MULTRET, 0)) {
|
lua_error(L);
|
||||||
lua_error(L);
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
inline void script(
|
||||||
inline void luajit_exception_handler(lua_State* L, int (*handler)(lua_State*, lua_CFunction) = detail::c_trampoline) {
|
lua_State* L, const string_view& code, const std::string& chunkname = detail::default_chunk_name(), load_mode mode = load_mode::any) {
|
||||||
#if SOL_IS_ON(SOL_USE_LUAJIT_EXCEPTION_TRAMPOLINE_I_)
|
|
||||||
if (L == nullptr) {
|
detail::typical_chunk_name_t basechunkname = {};
|
||||||
return;
|
const char* chunknametarget = detail::make_chunk_name(code, chunkname, basechunkname);
|
||||||
}
|
if (luaL_loadbufferx(L, code.data(), code.size(), chunknametarget, to_string(mode).c_str()) || lua_pcall(L, 0, LUA_MULTRET, 0)) {
|
||||||
#if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_)
|
lua_error(L);
|
||||||
luaL_checkstack(L, 1, detail::not_enough_stack_space_generic);
|
}
|
||||||
#endif // make sure stack doesn't overflow
|
}
|
||||||
lua_pushlightuserdata(L, (void*)handler);
|
|
||||||
auto pn = pop_n(L, 1);
|
inline void script_file(lua_State* L, const std::string& filename, load_mode mode = load_mode::any) {
|
||||||
luaJIT_setmode(L, -1, LUAJIT_MODE_WRAPCFUNC | LUAJIT_MODE_ON);
|
if (luaL_loadfilex(L, filename.c_str(), to_string(mode).c_str()) || lua_pcall(L, 0, LUA_MULTRET, 0)) {
|
||||||
#else
|
lua_error(L);
|
||||||
(void)L;
|
}
|
||||||
(void)handler;
|
}
|
||||||
#endif
|
|
||||||
}
|
inline void luajit_exception_handler(lua_State* L, int (*handler)(lua_State*, lua_CFunction) = detail::c_trampoline) {
|
||||||
|
#if SOL_IS_ON(SOL_USE_LUAJIT_EXCEPTION_TRAMPOLINE)
|
||||||
inline void luajit_exception_off(lua_State* L) {
|
if (L == nullptr) {
|
||||||
#if SOL_IS_ON(SOL_USE_LUAJIT_EXCEPTION_TRAMPOLINE_I_)
|
return;
|
||||||
if (L == nullptr) {
|
}
|
||||||
return;
|
#if SOL_IS_ON(SOL_SAFE_STACK_CHECK)
|
||||||
}
|
luaL_checkstack(L, 1, detail::not_enough_stack_space_generic);
|
||||||
luaJIT_setmode(L, -1, LUAJIT_MODE_WRAPCFUNC | LUAJIT_MODE_OFF);
|
#endif // make sure stack doesn't overflow
|
||||||
#else
|
lua_pushlightuserdata(L, (void*)handler);
|
||||||
(void)L;
|
auto pn = pop_n(L, 1);
|
||||||
#endif
|
luaJIT_setmode(L, -1, LUAJIT_MODE_WRAPCFUNC | LUAJIT_MODE_ON);
|
||||||
}
|
#else
|
||||||
} // namespace stack
|
(void)L;
|
||||||
} // namespace sol
|
(void)handler;
|
||||||
|
#endif
|
||||||
#endif // SOL_STACK_HPP
|
}
|
||||||
|
|
||||||
|
inline void luajit_exception_off(lua_State* L) {
|
||||||
|
#if SOL_IS_ON(SOL_USE_LUAJIT_EXCEPTION_TRAMPOLINE)
|
||||||
|
if (L == nullptr) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
luaJIT_setmode(L, -1, LUAJIT_MODE_WRAPCFUNC | LUAJIT_MODE_OFF);
|
||||||
|
#else
|
||||||
|
(void)L;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace stack_detail {
|
||||||
|
inline error get_error(lua_State* L, int target) {
|
||||||
|
auto maybe_exc = stack::check_get<error&>(L, target);
|
||||||
|
if (maybe_exc.has_value()) {
|
||||||
|
return maybe_exc.value();
|
||||||
|
}
|
||||||
|
return error(detail::direct_error, stack::get<std::string>(L, target));
|
||||||
|
}
|
||||||
|
|
||||||
|
inline detail::error_exception get_error_exception(lua_State* L, int target) {
|
||||||
|
auto maybe_exc = stack::check_get<detail::error_exception&>(L, target);
|
||||||
|
if (maybe_exc.has_value()) {
|
||||||
|
return maybe_exc.value();
|
||||||
|
}
|
||||||
|
return detail::error_exception(detail::direct_error, stack::get<std::string>(L, target));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} // namespace stack
|
||||||
|
} // namespace sol
|
||||||
|
|
||||||
|
#endif // SOL_STACK_HPP
|
||||||
|
|
|
||||||
196
extern/sol3/sol/stack/detail/pairs.hpp
vendored
196
extern/sol3/sol/stack/detail/pairs.hpp
vendored
|
|
@ -1,98 +1,98 @@
|
||||||
// sol2
|
// sol2
|
||||||
|
|
||||||
// The MIT License (MIT)
|
// The MIT License (MIT)
|
||||||
|
|
||||||
// Copyright (c) 2013-2021 Rapptz, ThePhD and contributors
|
// Copyright (c) 2013-2022 Rapptz, ThePhD and contributors
|
||||||
|
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
// this software and associated documentation files (the "Software"), to deal in
|
// this software and associated documentation files (the "Software"), to deal in
|
||||||
// the Software without restriction, including without limitation the rights to
|
// the Software without restriction, including without limitation the rights to
|
||||||
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||||
// the Software, and to permit persons to whom the Software is furnished to do so,
|
// the Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
// subject to the following conditions:
|
// subject to the following conditions:
|
||||||
|
|
||||||
// The above copyright notice and this Spermission notice shall be included in all
|
// The above copyright notice and this Spermission notice shall be included in all
|
||||||
// copies or substantial portions of the Software.
|
// copies or substantial portions of the Software.
|
||||||
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
#ifndef SOL_DETAIL_PAIRS_HPP
|
#ifndef SOL_DETAIL_PAIRS_HPP
|
||||||
#define SOL_DETAIL_PAIRS_HPP
|
#define SOL_DETAIL_PAIRS_HPP
|
||||||
|
|
||||||
#include <sol/version.hpp>
|
#include <sol/version.hpp>
|
||||||
|
|
||||||
#include <sol/stack.hpp>
|
#include <sol/stack.hpp>
|
||||||
#include <sol/stack_reference.hpp>
|
#include <sol/stack_reference.hpp>
|
||||||
#include <sol/protected_function.hpp>
|
#include <sol/protected_function.hpp>
|
||||||
#include <sol/assert.hpp>
|
#include <sol/assert.hpp>
|
||||||
|
|
||||||
#include <optional>
|
#include <optional>
|
||||||
|
|
||||||
namespace sol { namespace stack { namespace stack_detail {
|
namespace sol { namespace stack { namespace stack_detail {
|
||||||
|
|
||||||
inline bool maybe_push_lua_next_function(lua_State* L_) {
|
inline bool maybe_push_lua_next_function(lua_State* L_) {
|
||||||
stack::get_field<true, false>(L_, "next");
|
stack::get_field<true, false>(L_, "next");
|
||||||
bool is_next = stack::check<protected_function>(L_);
|
bool is_next = stack::check<protected_function>(L_);
|
||||||
if (is_next) {
|
if (is_next) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
stack::get_field<true, false>(L_, "table");
|
stack::get_field<true, false>(L_, "table");
|
||||||
stack::record tracking{};
|
stack::record tracking{};
|
||||||
if (!stack::loose_table_check(L_, -1, &no_panic, tracking)) {
|
if (!stack::loose_table_check(L_, -1, &no_panic, tracking)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
lua_getfield(L_, -1, "next");
|
lua_getfield(L_, -1, "next");
|
||||||
bool is_table_next_func = stack::check<protected_function>(L_, -1);
|
bool is_table_next_func = stack::check<protected_function>(L_, -1);
|
||||||
if (is_table_next_func) {
|
if (is_table_next_func) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
lua_pop(L_, 1);
|
lua_pop(L_, 1);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline std::optional<protected_function> find_lua_next_function(lua_State* L_) {
|
inline std::optional<protected_function> find_lua_next_function(lua_State* L_) {
|
||||||
if (maybe_push_lua_next_function(L_)) {
|
if (maybe_push_lua_next_function(L_)) {
|
||||||
return stack::pop<protected_function>(L_);
|
return stack::pop<protected_function>(L_);
|
||||||
}
|
}
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int c_lua_next(lua_State* L_) noexcept {
|
inline int c_lua_next(lua_State* L_) noexcept {
|
||||||
stack_reference table_stack_ref(L_, raw_index(1));
|
stack_reference table_stack_ref(L_, raw_index(1));
|
||||||
stateless_stack_reference key_stack_ref(L_, raw_index(2));
|
stateless_stack_reference key_stack_ref(L_, raw_index(2));
|
||||||
int result = lua_next(table_stack_ref.lua_state(), table_stack_ref.stack_index());
|
int result = lua_next(table_stack_ref.lua_state(), table_stack_ref.stack_index());
|
||||||
if (result == 0) {
|
if (result == 0) {
|
||||||
stack::push(L_, lua_nil);
|
stack::push(L_, lua_nil);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int readonly_pairs(lua_State* L_) noexcept {
|
inline int readonly_pairs(lua_State* L_) noexcept {
|
||||||
int pushed = 0;
|
int pushed = 0;
|
||||||
if (!maybe_push_lua_next_function(L_)) {
|
if (!maybe_push_lua_next_function(L_)) {
|
||||||
// we do not have the "next" function in the global namespace
|
// we do not have the "next" function in the global namespace
|
||||||
// from the "table" global entiry, use our own
|
// from the "table" global entiry, use our own
|
||||||
pushed += stack::push(L_, &c_lua_next);
|
pushed += stack::push(L_, &c_lua_next);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
pushed += 1;
|
pushed += 1;
|
||||||
}
|
}
|
||||||
int metatable_exists = lua_getmetatable(L_, 1);
|
int metatable_exists = lua_getmetatable(L_, 1);
|
||||||
sol_c_assert(metatable_exists == 1);
|
SOL_ASSERT(metatable_exists == 1);
|
||||||
const auto& index_key = to_string(sol::meta_function::index);
|
const auto& index_key = to_string(sol::meta_function::index);
|
||||||
lua_getfield(L_, lua_gettop(L_), index_key.c_str());
|
lua_getfield(L_, lua_gettop(L_), index_key.c_str());
|
||||||
lua_remove(L_, -2);
|
lua_remove(L_, -2);
|
||||||
pushed += 1;
|
pushed += 1;
|
||||||
pushed += stack::push(L_, lua_nil);
|
pushed += stack::push(L_, lua_nil);
|
||||||
return pushed;
|
return pushed;
|
||||||
}
|
}
|
||||||
|
|
||||||
}}} // sol::stack::stack_detail
|
}}} // sol::stack::stack_detail
|
||||||
|
|
||||||
#endif // SOL_DETAIL_PAIRS_HPP
|
#endif // SOL_DETAIL_PAIRS_HPP
|
||||||
|
|
|
||||||
2
extern/sol3/sol/stack_check.hpp
vendored
2
extern/sol3/sol/stack_check.hpp
vendored
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
// The MIT License (MIT)
|
// The MIT License (MIT)
|
||||||
|
|
||||||
// Copyright (c) 2013-2021 Rapptz, ThePhD and contributors
|
// Copyright (c) 2013-2022 Rapptz, ThePhD and contributors
|
||||||
|
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
// this software and associated documentation files (the "Software"), to deal in
|
// this software and associated documentation files (the "Software"), to deal in
|
||||||
|
|
|
||||||
2
extern/sol3/sol/stack_check_get.hpp
vendored
2
extern/sol3/sol/stack_check_get.hpp
vendored
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
// The MIT License (MIT)
|
// The MIT License (MIT)
|
||||||
|
|
||||||
// Copyright (c) 2013-2021 Rapptz, ThePhD and contributors
|
// Copyright (c) 2013-2022 Rapptz, ThePhD and contributors
|
||||||
|
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
// this software and associated documentation files (the "Software"), to deal in
|
// this software and associated documentation files (the "Software"), to deal in
|
||||||
|
|
|
||||||
21
extern/sol3/sol/stack_check_get_qualified.hpp
vendored
21
extern/sol3/sol/stack_check_get_qualified.hpp
vendored
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
// The MIT License (MIT)
|
// The MIT License (MIT)
|
||||||
|
|
||||||
// Copyright (c) 2013-2021 Rapptz, ThePhD and contributors
|
// Copyright (c) 2013-2022 Rapptz, ThePhD and contributors
|
||||||
|
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
// this software and associated documentation files (the "Software"), to deal in
|
// this software and associated documentation files (the "Software"), to deal in
|
||||||
|
|
@ -30,6 +30,13 @@
|
||||||
|
|
||||||
namespace sol { namespace stack {
|
namespace sol { namespace stack {
|
||||||
|
|
||||||
|
#if SOL_IS_ON(SOL_COMPILER_GCC)
|
||||||
|
#pragma GCC diagnostic push
|
||||||
|
#if !SOL_IS_ON(SOL_COMPILER_CLANG)
|
||||||
|
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace stack_detail {
|
namespace stack_detail {
|
||||||
template <typename OptionalType, typename T, typename Handler>
|
template <typename OptionalType, typename T, typename Handler>
|
||||||
OptionalType get_optional(lua_State* L, int index, Handler&& handler, record& tracking) {
|
OptionalType get_optional(lua_State* L, int index, Handler&& handler, record& tracking) {
|
||||||
|
|
@ -70,9 +77,8 @@ namespace sol { namespace stack {
|
||||||
actual* mem = static_cast<actual*>(memory);
|
actual* mem = static_cast<actual*>(memory);
|
||||||
return static_cast<actual>(*mem);
|
return static_cast<actual>(*mem);
|
||||||
}
|
}
|
||||||
actual r {};
|
|
||||||
if constexpr (!derive<element>::value) {
|
if constexpr (!derive<element>::value) {
|
||||||
return {};
|
return OptionalType();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
memory = detail::align_usertype_unique_tag<true, false>(memory);
|
memory = detail::align_usertype_unique_tag<true, false>(memory);
|
||||||
|
|
@ -80,6 +86,7 @@ namespace sol { namespace stack {
|
||||||
memory = detail::align_usertype_unique<actual, true, false>(memory);
|
memory = detail::align_usertype_unique<actual, true, false>(memory);
|
||||||
string_view ti = usertype_traits<element>::qualified_name();
|
string_view ti = usertype_traits<element>::qualified_name();
|
||||||
int cast_operation;
|
int cast_operation;
|
||||||
|
actual r {};
|
||||||
if constexpr (is_actual_type_rebindable_for_v<Tu>) {
|
if constexpr (is_actual_type_rebindable_for_v<Tu>) {
|
||||||
using rebound_actual_type = unique_usertype_rebind_actual_t<Tu, void>;
|
using rebound_actual_type = unique_usertype_rebind_actual_t<Tu, void>;
|
||||||
string_view rebind_ti = usertype_traits<rebound_actual_type>::qualified_name();
|
string_view rebind_ti = usertype_traits<rebound_actual_type>::qualified_name();
|
||||||
|
|
@ -103,19 +110,23 @@ namespace sol { namespace stack {
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return {};
|
return OptionalType();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (!check<T>(L, index, std::forward<Handler>(handler))) {
|
if (!check<T>(L, index, std::forward<Handler>(handler))) {
|
||||||
tracking.use(static_cast<int>(!lua_isnone(L, index)));
|
tracking.use(static_cast<int>(!lua_isnone(L, index)));
|
||||||
return {};
|
return OptionalType();
|
||||||
}
|
}
|
||||||
return OptionalType(stack_detail::unchecked_get<T>(L, index, tracking));
|
return OptionalType(stack_detail::unchecked_get<T>(L, index, tracking));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // namespace stack_detail
|
} // namespace stack_detail
|
||||||
|
|
||||||
|
#if SOL_IS_ON(SOL_COMPILER_GCC)
|
||||||
|
#pragma GCC diagnostic pop
|
||||||
|
#endif
|
||||||
|
|
||||||
template <typename T, typename>
|
template <typename T, typename>
|
||||||
struct qualified_check_getter {
|
struct qualified_check_getter {
|
||||||
typedef decltype(stack_detail::unchecked_get<T>(nullptr, -1, std::declval<record&>())) R;
|
typedef decltype(stack_detail::unchecked_get<T>(nullptr, -1, std::declval<record&>())) R;
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
// The MIT License (MIT)
|
// The MIT License (MIT)
|
||||||
|
|
||||||
// Copyright (c) 2013-2021 Rapptz, ThePhD and contributors
|
// Copyright (c) 2013-2022 Rapptz, ThePhD and contributors
|
||||||
|
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
// this software and associated documentation files (the "Software"), to deal in
|
// this software and associated documentation files (the "Software"), to deal in
|
||||||
|
|
@ -32,7 +32,7 @@
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
#if SOL_IS_ON(SOL_STD_VARIANT_I_)
|
#if SOL_IS_ON(SOL_STD_VARIANT)
|
||||||
#include <variant>
|
#include <variant>
|
||||||
#endif // variant shenanigans (thanks, Mac OSX)
|
#endif // variant shenanigans (thanks, Mac OSX)
|
||||||
|
|
||||||
|
|
@ -76,7 +76,7 @@ namespace sol { namespace stack {
|
||||||
int isnum = 0;
|
int isnum = 0;
|
||||||
const lua_Number value = lua_tonumberx(L, index, &isnum);
|
const lua_Number value = lua_tonumberx(L, index, &isnum);
|
||||||
if (isnum != 0) {
|
if (isnum != 0) {
|
||||||
#if SOL_IS_ON(SOL_NUMBER_PRECISION_CHECKS_I_)
|
#if SOL_IS_ON(SOL_NUMBER_PRECISION_CHECKS)
|
||||||
const auto integer_value = llround(value);
|
const auto integer_value = llround(value);
|
||||||
if (static_cast<lua_Number>(integer_value) == value) {
|
if (static_cast<lua_Number>(integer_value) == value) {
|
||||||
tracking.use(1);
|
tracking.use(1);
|
||||||
|
|
@ -139,7 +139,7 @@ namespace sol { namespace stack {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#if SOL_IS_ON(SOL_STD_VARIANT_I_)
|
#if SOL_IS_ON(SOL_STD_VARIANT)
|
||||||
template <typename... Tn, typename C>
|
template <typename... Tn, typename C>
|
||||||
struct unqualified_check_getter<std::variant<Tn...>, C> {
|
struct unqualified_check_getter<std::variant<Tn...>, C> {
|
||||||
typedef std::variant<Tn...> V;
|
typedef std::variant<Tn...> V;
|
||||||
|
|
|
||||||
4
extern/sol3/sol/stack_check_qualified.hpp
vendored
4
extern/sol3/sol/stack_check_qualified.hpp
vendored
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
// The MIT License (MIT)
|
// The MIT License (MIT)
|
||||||
|
|
||||||
// Copyright (c) 2013-2021 Rapptz, ThePhD and contributors
|
// Copyright (c) 2013-2022 Rapptz, ThePhD and contributors
|
||||||
|
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
// this software and associated documentation files (the "Software"), to deal in
|
// this software and associated documentation files (the "Software"), to deal in
|
||||||
|
|
@ -28,7 +28,7 @@
|
||||||
|
|
||||||
namespace sol { namespace stack {
|
namespace sol { namespace stack {
|
||||||
|
|
||||||
template <typename X, type expected, typename>
|
template <typename X, typename>
|
||||||
struct qualified_checker {
|
struct qualified_checker {
|
||||||
template <typename Handler>
|
template <typename Handler>
|
||||||
static bool check(lua_State* L, int index, Handler&& handler, record& tracking) {
|
static bool check(lua_State* L, int index, Handler&& handler, record& tracking) {
|
||||||
|
|
|
||||||
135
extern/sol3/sol/stack_check_unqualified.hpp
vendored
135
extern/sol3/sol/stack_check_unqualified.hpp
vendored
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
// The MIT License (MIT)
|
// The MIT License (MIT)
|
||||||
|
|
||||||
// Copyright (c) 2013-2021 Rapptz, ThePhD and contributors
|
// Copyright (c) 2013-2022 Rapptz, ThePhD and contributors
|
||||||
|
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
// this software and associated documentation files (the "Software"), to deal in
|
// this software and associated documentation files (the "Software"), to deal in
|
||||||
|
|
@ -32,7 +32,7 @@
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
#if SOL_IS_ON(SOL_STD_VARIANT_I_)
|
#if SOL_IS_ON(SOL_STD_VARIANT)
|
||||||
#include <variant>
|
#include <variant>
|
||||||
#endif // variant shenanigans
|
#endif // variant shenanigans
|
||||||
|
|
||||||
|
|
@ -116,7 +116,7 @@ namespace sol { namespace stack {
|
||||||
}
|
}
|
||||||
else if constexpr (meta::any_same_v<T,
|
else if constexpr (meta::any_same_v<T,
|
||||||
char
|
char
|
||||||
#if SOL_IS_ON(SOL_CHAR8_T_I_)
|
#if SOL_IS_ON(SOL_CHAR8_T)
|
||||||
,
|
,
|
||||||
char8_t
|
char8_t
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -129,7 +129,7 @@ namespace sol { namespace stack {
|
||||||
tracking.use(1);
|
tracking.use(1);
|
||||||
#if SOL_LUA_VERSION_I_ >= 503
|
#if SOL_LUA_VERSION_I_ >= 503
|
||||||
// Lua 5.3 and greater checks for numeric precision
|
// Lua 5.3 and greater checks for numeric precision
|
||||||
#if SOL_IS_ON(SOL_STRINGS_ARE_NUMBERS_I_)
|
#if SOL_IS_ON(SOL_STRINGS_ARE_NUMBERS)
|
||||||
// imprecise, sloppy conversions
|
// imprecise, sloppy conversions
|
||||||
int isnum = 0;
|
int isnum = 0;
|
||||||
lua_tointegerx(L_, index, &isnum);
|
lua_tointegerx(L_, index, &isnum);
|
||||||
|
|
@ -138,7 +138,7 @@ namespace sol { namespace stack {
|
||||||
// expected type, actual type
|
// expected type, actual type
|
||||||
handler(L_, index, type::number, type_of(L_, index), detail::not_a_number_or_number_string_integral);
|
handler(L_, index, type::number, type_of(L_, index), detail::not_a_number_or_number_string_integral);
|
||||||
}
|
}
|
||||||
#elif SOL_IS_ON(SOL_NUMBER_PRECISION_CHECKS_I_)
|
#elif SOL_IS_ON(SOL_NUMBER_PRECISION_CHECKS)
|
||||||
// this check is precise, do not convert
|
// this check is precise, do not convert
|
||||||
if (lua_isinteger(L_, index) == 1) {
|
if (lua_isinteger(L_, index) == 1) {
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -160,7 +160,7 @@ namespace sol { namespace stack {
|
||||||
return success;
|
return success;
|
||||||
#else
|
#else
|
||||||
// Lua 5.2 and below checks
|
// Lua 5.2 and below checks
|
||||||
#if SOL_IS_OFF(SOL_STRINGS_ARE_NUMBERS_I_)
|
#if SOL_IS_OFF(SOL_STRINGS_ARE_NUMBERS)
|
||||||
// must pre-check, because it will convert
|
// must pre-check, because it will convert
|
||||||
type t = type_of(L_, index);
|
type t = type_of(L_, index);
|
||||||
if (t != type::number) {
|
if (t != type::number) {
|
||||||
|
|
@ -170,7 +170,7 @@ namespace sol { namespace stack {
|
||||||
}
|
}
|
||||||
#endif // Do not allow strings to be numbers
|
#endif // Do not allow strings to be numbers
|
||||||
|
|
||||||
#if SOL_IS_ON(SOL_NUMBER_PRECISION_CHECKS_I_)
|
#if SOL_IS_ON(SOL_NUMBER_PRECISION_CHECKS)
|
||||||
int isnum = 0;
|
int isnum = 0;
|
||||||
const lua_Number v = lua_tonumberx(L_, index, &isnum);
|
const lua_Number v = lua_tonumberx(L_, index, &isnum);
|
||||||
const bool success = isnum != 0 && static_cast<lua_Number>(llround(v)) == v;
|
const bool success = isnum != 0 && static_cast<lua_Number>(llround(v)) == v;
|
||||||
|
|
@ -179,9 +179,9 @@ namespace sol { namespace stack {
|
||||||
#endif // Safe numerics and number precision checking
|
#endif // Safe numerics and number precision checking
|
||||||
if (!success) {
|
if (!success) {
|
||||||
// Use defines to provide a better error message!
|
// Use defines to provide a better error message!
|
||||||
#if SOL_IS_ON(SOL_STRINGS_ARE_NUMBERS_I_)
|
#if SOL_IS_ON(SOL_STRINGS_ARE_NUMBERS)
|
||||||
handler(L_, index, type::number, type_of(L_, index), detail::not_a_number_or_number_string);
|
handler(L_, index, type::number, type_of(L_, index), detail::not_a_number_or_number_string);
|
||||||
#elif SOL_IS_ON(SOL_NUMBER_PRECISION_CHECKS_I_)
|
#elif SOL_IS_ON(SOL_NUMBER_PRECISION_CHECKS)
|
||||||
handler(L_, index, type::number, t, detail::not_a_number_or_number_string);
|
handler(L_, index, type::number, t, detail::not_a_number_or_number_string);
|
||||||
#else
|
#else
|
||||||
handler(L_, index, type::number, t, detail::not_a_number);
|
handler(L_, index, type::number, t, detail::not_a_number);
|
||||||
|
|
@ -192,7 +192,7 @@ namespace sol { namespace stack {
|
||||||
}
|
}
|
||||||
else if constexpr (std::is_floating_point_v<T> || std::is_same_v<T, lua_Number>) {
|
else if constexpr (std::is_floating_point_v<T> || std::is_same_v<T, lua_Number>) {
|
||||||
tracking.use(1);
|
tracking.use(1);
|
||||||
#if SOL_IS_ON(SOL_STRINGS_ARE_NUMBERS_I_)
|
#if SOL_IS_ON(SOL_STRINGS_ARE_NUMBERS)
|
||||||
bool success = lua_isnumber(L_, index) == 1;
|
bool success = lua_isnumber(L_, index) == 1;
|
||||||
if (!success) {
|
if (!success) {
|
||||||
// expected type, actual type
|
// expected type, actual type
|
||||||
|
|
@ -218,6 +218,7 @@ namespace sol { namespace stack {
|
||||||
}
|
}
|
||||||
else if constexpr (is_unique_usertype_v<T>) {
|
else if constexpr (is_unique_usertype_v<T>) {
|
||||||
using element = unique_usertype_element_t<T>;
|
using element = unique_usertype_element_t<T>;
|
||||||
|
using element_no_cv = meta::unqualified_t<element>;
|
||||||
using actual = unique_usertype_actual_t<T>;
|
using actual = unique_usertype_actual_t<T>;
|
||||||
const type indextype = type_of(L_, index);
|
const type indextype = type_of(L_, index);
|
||||||
tracking.use(1);
|
tracking.use(1);
|
||||||
|
|
@ -229,7 +230,7 @@ namespace sol { namespace stack {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
int metatableindex = lua_gettop(L_);
|
int metatableindex = lua_gettop(L_);
|
||||||
if (stack_detail::check_metatable<d::u<element>>(L_, metatableindex)) {
|
if (stack_detail::check_metatable<d::u<element_no_cv>>(L_, metatableindex)) {
|
||||||
void* memory = lua_touserdata(L_, index);
|
void* memory = lua_touserdata(L_, index);
|
||||||
memory = detail::align_usertype_unique_destructor(memory);
|
memory = detail::align_usertype_unique_destructor(memory);
|
||||||
detail::unique_destructor& pdx = *static_cast<detail::unique_destructor*>(memory);
|
detail::unique_destructor& pdx = *static_cast<detail::unique_destructor*>(memory);
|
||||||
|
|
@ -371,7 +372,7 @@ namespace sol { namespace stack {
|
||||||
}
|
}
|
||||||
return stack::unqualified_check<ValueType>(L_, index, &no_panic, tracking);
|
return stack::unqualified_check<ValueType>(L_, index, &no_panic, tracking);
|
||||||
}
|
}
|
||||||
#if SOL_IS_ON(SOL_GET_FUNCTION_POINTER_UNSAFE_I_)
|
#if SOL_IS_ON(SOL_GET_FUNCTION_POINTER_UNSAFE)
|
||||||
else if constexpr (std::is_function_v<T> || (std::is_pointer_v<T> && std::is_function_v<std::remove_pointer_t<T>>)) {
|
else if constexpr (std::is_function_v<T> || (std::is_pointer_v<T> && std::is_function_v<std::remove_pointer_t<T>>)) {
|
||||||
return stack_detail::check_function_pointer<std::remove_pointer_t<T>>(L_, index, std::forward<Handler>(handler), tracking);
|
return stack_detail::check_function_pointer<std::remove_pointer_t<T>>(L_, index, std::forward<Handler>(handler), tracking);
|
||||||
}
|
}
|
||||||
|
|
@ -388,9 +389,7 @@ namespace sol { namespace stack {
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
else if constexpr (meta::is_specialization_of_v<T, user>) {
|
else if constexpr (meta::is_specialization_of_v<T, user>) {
|
||||||
unqualified_checker<lightuserdata_value, type::userdata> c;
|
return stack::unqualified_check<detail::as_value_tag<lightuserdata_value>>(L_, index, std::forward<Handler>(handler), tracking);
|
||||||
(void)c;
|
|
||||||
return c.check(L_, index, std::forward<Handler>(handler), tracking);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if constexpr (std::is_pointer_v<T>) {
|
if constexpr (std::is_pointer_v<T>) {
|
||||||
|
|
@ -508,13 +507,13 @@ namespace sol { namespace stack {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
#if SOL_IS_ON(SOL_USE_INTEROP_I_)
|
#if SOL_IS_ON(SOL_USE_INTEROP)
|
||||||
if (stack_detail::interop_check<U>(L_, index, indextype, handler, tracking)) {
|
if (stack_detail::interop_check<U>(L_, index, indextype, handler, tracking)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
#endif // interop extensibility
|
#endif // interop extensibility
|
||||||
tracking.use(1);
|
tracking.use(1);
|
||||||
#if SOL_IS_ON(SOL_GET_FUNCTION_POINTER_UNSAFE_I_)
|
#if SOL_IS_ON(SOL_GET_FUNCTION_POINTER_UNSAFE)
|
||||||
if (lua_iscfunction(L_, index) != 0) {
|
if (lua_iscfunction(L_, index) != 0) {
|
||||||
// a potential match...
|
// a potential match...
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -539,7 +538,7 @@ namespace sol { namespace stack {
|
||||||
bool success = false;
|
bool success = false;
|
||||||
bool has_derived = derive<T>::value || weak_derive<T>::value;
|
bool has_derived = derive<T>::value || weak_derive<T>::value;
|
||||||
if (has_derived) {
|
if (has_derived) {
|
||||||
#if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_)
|
#if SOL_IS_ON(SOL_SAFE_STACK_CHECK)
|
||||||
luaL_checkstack(L_, 1, detail::not_enough_stack_space_string);
|
luaL_checkstack(L_, 1, detail::not_enough_stack_space_string);
|
||||||
#endif // make sure stack doesn't overflow
|
#endif // make sure stack doesn't overflow
|
||||||
auto pn = stack::pop_n(L_, 1);
|
auto pn = stack::pop_n(L_, 1);
|
||||||
|
|
@ -579,6 +578,104 @@ namespace sol { namespace stack {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template <typename T, std::size_t N, type expect>
|
||||||
|
struct unqualified_checker<exhaustive_until<T, N>, expect> {
|
||||||
|
template <typename K, typename V, typename Handler>
|
||||||
|
static bool check_two(types<K, V>, lua_State* arg_L, int relindex, type, Handler&& handler, record& tracking) {
|
||||||
|
tracking.use(1);
|
||||||
|
|
||||||
|
#if SOL_IS_ON(SOL_SAFE_STACK_CHECK)
|
||||||
|
luaL_checkstack(arg_L, 3, detail::not_enough_stack_space_generic);
|
||||||
|
#endif // make sure stack doesn't overflow
|
||||||
|
|
||||||
|
int index = lua_absindex(arg_L, relindex);
|
||||||
|
lua_pushnil(arg_L);
|
||||||
|
while (lua_next(arg_L, index) != 0) {
|
||||||
|
const bool is_key_okay = stack::check<K>(arg_L, -2, std::forward<Handler>(handler), tracking);
|
||||||
|
if (!is_key_okay) {
|
||||||
|
lua_pop(arg_L, 2);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
const bool is_value_okay = stack::check<V>(arg_L, -1, std::forward<Handler>(handler), tracking);
|
||||||
|
if (!is_value_okay) {
|
||||||
|
lua_pop(arg_L, 2);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
lua_pop(arg_L, 1);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename V, typename Handler>
|
||||||
|
static bool check_one(types<V>, lua_State* arg_L, int relindex, type, Handler&& handler, record& tracking) {
|
||||||
|
tracking.use(1);
|
||||||
|
|
||||||
|
size_t index = lua_absindex(arg_L, relindex);
|
||||||
|
// Zzzz slower but necessary thanks to the lower version API and missing functions qq
|
||||||
|
std::size_t idx = 0;
|
||||||
|
int vi = 0;
|
||||||
|
for (lua_Integer i = 0;; (void)(i += lua_size<V>::value), lua_pop(arg_L, static_cast<int>(vi))) {
|
||||||
|
vi = 0;
|
||||||
|
if (idx >= N) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
#if SOL_IS_ON(SOL_SAFE_STACK_CHECK)
|
||||||
|
luaL_checkstack(arg_L, 2, detail::not_enough_stack_space_generic);
|
||||||
|
#endif // make sure stack doesn't overflow
|
||||||
|
bool isnil = false;
|
||||||
|
for (; vi < static_cast<int>(lua_size<V>::value); ++vi) {
|
||||||
|
lua_pushinteger(arg_L, i);
|
||||||
|
lua_gettable(arg_L, static_cast<int>(index));
|
||||||
|
type vt = type_of(arg_L, -1);
|
||||||
|
isnil = vt == type::lua_nil;
|
||||||
|
if (isnil) {
|
||||||
|
if (i == 0) {
|
||||||
|
vi += 1;
|
||||||
|
goto loop_continue;
|
||||||
|
}
|
||||||
|
lua_pop(arg_L, static_cast<int>(vi + 1));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!stack::check<V>(arg_L, -lua_size<V>::value, std::forward<Handler>(handler), tracking)) {
|
||||||
|
lua_pop(arg_L, lua_size<V>::value);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
++idx;
|
||||||
|
loop_continue:;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename Handler>
|
||||||
|
static bool check(lua_State* arg_L, int index, Handler&& handler, record& tracking) {
|
||||||
|
using Tu = meta::unqualified_t<T>;
|
||||||
|
if constexpr (is_container_v<Tu>) {
|
||||||
|
if constexpr (meta::is_associative<Tu>::value) {
|
||||||
|
typedef typename Tu::value_type P;
|
||||||
|
typedef typename P::first_type K;
|
||||||
|
typedef typename P::second_type V;
|
||||||
|
return check_two(types<K, V>(), arg_L, index, expect, std::forward<Handler>(handler), tracking);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
typedef typename Tu::value_type V;
|
||||||
|
return check_one(types<V>(), arg_L, index, expect, std::forward<Handler>(handler), tracking);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
unqualified_checker<Tu, expect> c {};
|
||||||
|
return c.check(arg_L, index, std::forward<Handler>(handler), tracking);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T, type expect>
|
||||||
|
struct unqualified_checker<non_exhaustive<T>, expect> {
|
||||||
|
template <typename Handler>
|
||||||
|
static bool check(lua_State* arg_L, int index, Handler&& handler, record& tracking) {
|
||||||
|
return stack::check<T>(arg_L, index, std::forward<Handler>(handler), tracking);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
template <typename... Args>
|
template <typename... Args>
|
||||||
struct unqualified_checker<std::tuple<Args...>, type::poly> {
|
struct unqualified_checker<std::tuple<Args...>, type::poly> {
|
||||||
template <typename Handler>
|
template <typename Handler>
|
||||||
|
|
@ -595,7 +692,7 @@ namespace sol { namespace stack {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#if SOL_IS_ON(SOL_STD_VARIANT_I_)
|
#if SOL_IS_ON(SOL_STD_VARIANT)
|
||||||
|
|
||||||
template <typename... Tn>
|
template <typename... Tn>
|
||||||
struct unqualified_checker<std::variant<Tn...>, type::poly> {
|
struct unqualified_checker<std::variant<Tn...>, type::poly> {
|
||||||
|
|
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue