mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-05-18 09:58:59 -05:00
Centralize the extraction of Lua values and fix bug when trying to extract the first parameter of a Lua parameter pack
This commit is contained in:
+1
-1
Submodule ext/ghoul updated: cbb8bbf7c3...24daa298c6
@@ -41,8 +41,6 @@ public:
|
||||
using TemplateProperty<std::vector<double>>::operator=;
|
||||
|
||||
protected:
|
||||
std::vector<double> fromLuaConversion(lua_State* state, bool& success) const override;
|
||||
void toLuaConversion(lua_State* state) const override;
|
||||
std::string toStringConversion() const override;
|
||||
};
|
||||
|
||||
|
||||
@@ -41,8 +41,6 @@ public:
|
||||
using TemplateProperty<std::vector<int>>::operator=;
|
||||
|
||||
protected:
|
||||
std::vector<int> fromLuaConversion(lua_State* state, bool& success) const override;
|
||||
void toLuaConversion(lua_State* state) const override;
|
||||
std::string toStringConversion() const override;
|
||||
};
|
||||
|
||||
|
||||
@@ -42,9 +42,6 @@ public:
|
||||
using TemplateProperty<std::vector<std::string>>::operator=;
|
||||
|
||||
protected:
|
||||
std::vector<std::string> fromLuaConversion(lua_State* state,
|
||||
bool& success) const override;
|
||||
void toLuaConversion(lua_State* state) const override;
|
||||
std::string toStringConversion() const override;
|
||||
};
|
||||
|
||||
|
||||
@@ -36,6 +36,10 @@ public:
|
||||
ListProperty(Property::PropertyInfo info, std::vector<T> values);
|
||||
|
||||
virtual ~ListProperty() override = 0;
|
||||
|
||||
protected:
|
||||
std::vector<T> fromLuaConversion(lua_State* state) const override;
|
||||
void toLuaConversion(lua_State* state) const override;
|
||||
};
|
||||
|
||||
} // namespace openspace::properties
|
||||
|
||||
@@ -32,5 +32,15 @@ ListProperty<T>::ListProperty(Property::PropertyInfo info, std::vector<T> values
|
||||
template <typename T>
|
||||
ListProperty<T>::~ListProperty() {}
|
||||
|
||||
template <typename T>
|
||||
std::vector<T> ListProperty<T>::fromLuaConversion(lua_State* state) const {
|
||||
return ghoul::lua::value<std::vector<T>>(state);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void ListProperty<T>::toLuaConversion(lua_State* state) const {
|
||||
ghoul::lua::push(state, TemplateProperty<std::vector<T>>::_value);
|
||||
}
|
||||
|
||||
} // namespace openspace::properties
|
||||
|
||||
|
||||
@@ -45,9 +45,6 @@ public:
|
||||
int typeLua() const override;
|
||||
|
||||
using TemplateProperty<glm::dmat2x2>::operator=;
|
||||
|
||||
protected:
|
||||
glm::dmat2x2 fromLuaConversion(lua_State* state, bool& success) const override;
|
||||
};
|
||||
|
||||
} // namespace openspace::properties
|
||||
|
||||
@@ -45,9 +45,6 @@ public:
|
||||
int typeLua() const override;
|
||||
|
||||
using TemplateProperty<glm::dmat3x3>::operator=;
|
||||
|
||||
protected:
|
||||
glm::dmat3x3 fromLuaConversion(lua_State* state, bool& success) const override;
|
||||
};
|
||||
|
||||
} // namespace openspace::properties
|
||||
|
||||
@@ -45,9 +45,6 @@ public:
|
||||
int typeLua() const override;
|
||||
|
||||
using TemplateProperty<glm::dmat4x4>::operator=;
|
||||
|
||||
protected:
|
||||
glm::dmat4x4 fromLuaConversion(lua_State* state, bool& success) const override;
|
||||
};
|
||||
|
||||
} // namespace openspace::properties
|
||||
|
||||
@@ -45,9 +45,6 @@ public:
|
||||
int typeLua() const override;
|
||||
|
||||
using TemplateProperty<glm::mat2x2>::operator=;
|
||||
|
||||
protected:
|
||||
glm::mat2x2 fromLuaConversion(lua_State* state, bool& success) const override;
|
||||
};
|
||||
|
||||
} // namespace openspace::properties
|
||||
|
||||
@@ -45,9 +45,6 @@ public:
|
||||
int typeLua() const override;
|
||||
|
||||
using TemplateProperty<glm::mat3x3>::operator=;
|
||||
|
||||
protected:
|
||||
glm::mat3x3 fromLuaConversion(lua_State* state, bool& success) const override;
|
||||
};
|
||||
|
||||
} // namespace openspace::properties
|
||||
|
||||
@@ -45,9 +45,6 @@ public:
|
||||
int typeLua() const override;
|
||||
|
||||
using TemplateProperty<glm::mat4x4>::operator=;
|
||||
|
||||
protected:
|
||||
glm::mat4x4 fromLuaConversion(lua_State* state, bool& success) const override;
|
||||
};
|
||||
|
||||
} // namespace openspace::properties
|
||||
|
||||
@@ -66,7 +66,7 @@ protected:
|
||||
static const std::string SteppingValueKey;
|
||||
static const std::string ExponentValueKey;
|
||||
|
||||
virtual T fromLuaConversion(lua_State* state, bool& success) const override = 0;
|
||||
T fromLuaConversion(lua_State* state) const override;
|
||||
virtual void toLuaConversion(lua_State* state) const override;
|
||||
virtual std::string toStringConversion() const override;
|
||||
|
||||
|
||||
@@ -166,12 +166,9 @@ void NumericalProperty<T>::setInterpolationTarget(std::any value) {
|
||||
|
||||
template <typename T>
|
||||
void NumericalProperty<T>::setLuaInterpolationTarget(lua_State* state) {
|
||||
bool success = false;
|
||||
T targetValue = fromLuaConversion(state, success);
|
||||
if (success) {
|
||||
_interpolationStart = TemplateProperty<T>::_value;
|
||||
_interpolationEnd = std::move(targetValue);
|
||||
}
|
||||
T targetValue = fromLuaConversion(state);
|
||||
_interpolationStart = TemplateProperty<T>::_value;
|
||||
_interpolationEnd = std::move(targetValue);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
@@ -191,6 +188,11 @@ void NumericalProperty<T>::toLuaConversion(lua_State* state) const {
|
||||
ghoul::lua::push(state, TemplateProperty<T>::_value);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T NumericalProperty<T>::fromLuaConversion(lua_State* state) const {
|
||||
return ghoul::lua::value<T>(state);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
std::string NumericalProperty<T>::toStringConversion() const {
|
||||
return formatJson(TemplateProperty<T>::_value);
|
||||
|
||||
@@ -43,8 +43,6 @@ public:
|
||||
using TemplateProperty<bool>::operator=;
|
||||
|
||||
protected:
|
||||
bool fromLuaConversion(lua_State* state, bool& success) const override;
|
||||
void toLuaConversion(lua_State* state) const override;
|
||||
std::string toStringConversion() const override;
|
||||
};
|
||||
|
||||
|
||||
@@ -44,9 +44,6 @@ public:
|
||||
int typeLua() const override;
|
||||
|
||||
using TemplateProperty<double>::operator=;
|
||||
|
||||
protected:
|
||||
double fromLuaConversion(lua_State* state, bool& success) const override;
|
||||
};
|
||||
|
||||
} // namespace openspace::properties
|
||||
|
||||
@@ -44,9 +44,6 @@ public:
|
||||
int typeLua() const override;
|
||||
|
||||
using TemplateProperty<float>::operator=;
|
||||
|
||||
protected:
|
||||
float fromLuaConversion(lua_State* state, bool& success) const override;
|
||||
};
|
||||
|
||||
} // namespace openspace::properties
|
||||
|
||||
@@ -44,9 +44,6 @@ public:
|
||||
int typeLua() const override;
|
||||
|
||||
using TemplateProperty<int>::operator=;
|
||||
|
||||
protected:
|
||||
int fromLuaConversion(lua_State* state, bool& success) const override;
|
||||
};
|
||||
|
||||
} // namespace openspace::properties
|
||||
|
||||
@@ -45,9 +45,6 @@ public:
|
||||
int typeLua() const override;
|
||||
|
||||
using TemplateProperty<long>::operator=;
|
||||
|
||||
protected:
|
||||
long fromLuaConversion(lua_State* state, bool& success) const override;
|
||||
};
|
||||
|
||||
} // namespace openspace::properties
|
||||
|
||||
@@ -58,9 +58,6 @@ public:
|
||||
int typeLua() const override;
|
||||
|
||||
using TemplateProperty<short>::operator=;
|
||||
|
||||
protected:
|
||||
short fromLuaConversion(lua_State* state, bool& success) const override;
|
||||
};
|
||||
|
||||
} // namespace openspace::properties
|
||||
|
||||
@@ -45,9 +45,6 @@ public:
|
||||
int typeLua() const override;
|
||||
|
||||
using TemplateProperty<unsigned int>::operator=;
|
||||
|
||||
protected:
|
||||
unsigned int fromLuaConversion(lua_State* state, bool& success) const override;
|
||||
};
|
||||
|
||||
} // namespace openspace::properties
|
||||
|
||||
@@ -45,9 +45,6 @@ public:
|
||||
int typeLua() const override;
|
||||
|
||||
using TemplateProperty<unsigned long>::operator=;
|
||||
|
||||
protected:
|
||||
unsigned long fromLuaConversion(lua_State* state, bool& success) const override;
|
||||
};
|
||||
|
||||
} // namespace openspace::properties
|
||||
|
||||
@@ -45,9 +45,6 @@ public:
|
||||
int typeLua() const override;
|
||||
|
||||
using TemplateProperty<unsigned short>::operator=;
|
||||
|
||||
protected:
|
||||
unsigned short fromLuaConversion(lua_State* state, bool& success) const override;
|
||||
};
|
||||
|
||||
} // namespace openspace::properties
|
||||
|
||||
@@ -114,8 +114,7 @@ public:
|
||||
using TemplateProperty<std::set<std::string>>::operator=;
|
||||
|
||||
protected:
|
||||
std::set<std::string> fromLuaConversion(lua_State* state,
|
||||
bool& success) const override;
|
||||
std::set<std::string> fromLuaConversion(lua_State* state) const override;
|
||||
|
||||
void toLuaConversion(lua_State* state) const override;
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ public:
|
||||
operator std::string_view() const;
|
||||
|
||||
protected:
|
||||
std::string fromLuaConversion(lua_State* state, bool& success) const override;
|
||||
std::string fromLuaConversion(lua_State* state) const override;
|
||||
void toLuaConversion(lua_State* state) const override;
|
||||
std::string toStringConversion() const override;
|
||||
};
|
||||
|
||||
@@ -188,10 +188,9 @@ protected:
|
||||
* and returns it. This method has to be specialized for each new type.
|
||||
*
|
||||
* \param state The Lua state from which the value will be decoded
|
||||
* \param success Set to true `true` if the decoding succeeded; `false` otherwise
|
||||
* \return the decoded value
|
||||
*/
|
||||
virtual T fromLuaConversion(lua_State* state, bool& success) const = 0;
|
||||
virtual T fromLuaConversion(lua_State* state) const = 0;
|
||||
|
||||
/**
|
||||
* Encodes the stored value into a Lua object and pushes that object onto
|
||||
|
||||
@@ -87,11 +87,7 @@ bool TemplateProperty<T>::getLuaValue(lua_State* state) const {
|
||||
template <typename T>
|
||||
bool TemplateProperty<T>::setLuaValue(lua_State* state) {
|
||||
try {
|
||||
bool success;
|
||||
T thisValue = fromLuaConversion(state, success);
|
||||
if (!success) {
|
||||
return false;
|
||||
}
|
||||
T thisValue = fromLuaConversion(state);
|
||||
set(std::any(thisValue));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -43,9 +43,6 @@ public:
|
||||
int typeLua() const override;
|
||||
|
||||
using TemplateProperty<glm::dvec2>::operator=;
|
||||
|
||||
protected:
|
||||
glm::dvec2 fromLuaConversion(lua_State* state, bool& success) const override;
|
||||
};
|
||||
|
||||
} // namespace openspace::properties
|
||||
|
||||
@@ -43,9 +43,6 @@ public:
|
||||
int typeLua() const override;
|
||||
|
||||
using TemplateProperty<glm::dvec3>::operator=;
|
||||
|
||||
protected:
|
||||
glm::dvec3 fromLuaConversion(lua_State* state, bool& success) const override;
|
||||
};
|
||||
|
||||
} // namespace openspace::properties
|
||||
|
||||
@@ -43,9 +43,6 @@ public:
|
||||
int typeLua() const override;
|
||||
|
||||
using TemplateProperty<glm::dvec4>::operator=;
|
||||
|
||||
protected:
|
||||
glm::dvec4 fromLuaConversion(lua_State* state, bool& success) const override;
|
||||
};
|
||||
|
||||
} // namespace openspace::properties
|
||||
|
||||
@@ -43,9 +43,6 @@ public:
|
||||
int typeLua() const override;
|
||||
|
||||
using TemplateProperty<glm::ivec2>::operator=;
|
||||
|
||||
protected:
|
||||
glm::ivec2 fromLuaConversion(lua_State* state, bool& success) const override;
|
||||
};
|
||||
|
||||
} // namespace openspace::properties
|
||||
|
||||
@@ -43,9 +43,6 @@ public:
|
||||
int typeLua() const override;
|
||||
|
||||
using TemplateProperty<glm::ivec3>::operator=;
|
||||
|
||||
protected:
|
||||
glm::ivec3 fromLuaConversion(lua_State* state, bool& success) const override;
|
||||
};
|
||||
|
||||
} // namespace openspace::properties
|
||||
|
||||
@@ -43,9 +43,6 @@ public:
|
||||
int typeLua() const override;
|
||||
|
||||
using TemplateProperty<glm::ivec4>::operator=;
|
||||
|
||||
protected:
|
||||
glm::ivec4 fromLuaConversion(lua_State* state, bool& success) const override;
|
||||
};
|
||||
|
||||
} // namespace openspace::properties
|
||||
|
||||
@@ -43,9 +43,6 @@ public:
|
||||
int typeLua() const override;
|
||||
|
||||
using TemplateProperty<glm::uvec2>::operator=;
|
||||
|
||||
protected:
|
||||
glm::uvec2 fromLuaConversion(lua_State* state, bool& success) const override;
|
||||
};
|
||||
|
||||
} // namespace openspace::properties
|
||||
|
||||
@@ -43,9 +43,6 @@ public:
|
||||
int typeLua() const override;
|
||||
|
||||
using TemplateProperty<glm::uvec3>::operator=;
|
||||
|
||||
protected:
|
||||
glm::uvec3 fromLuaConversion(lua_State* state, bool& success) const override;
|
||||
};
|
||||
|
||||
} // namespace openspace::properties
|
||||
|
||||
@@ -43,9 +43,6 @@ public:
|
||||
int typeLua() const override;
|
||||
|
||||
using TemplateProperty<glm::uvec4>::operator=;
|
||||
|
||||
protected:
|
||||
glm::uvec4 fromLuaConversion(lua_State* state, bool& success) const override;
|
||||
};
|
||||
|
||||
} // namespace openspace::properties
|
||||
|
||||
@@ -43,9 +43,6 @@ public:
|
||||
int typeLua() const override;
|
||||
|
||||
using TemplateProperty<glm::vec2>::operator=;
|
||||
|
||||
protected:
|
||||
glm::vec2 fromLuaConversion(lua_State* state, bool& success) const override;
|
||||
};
|
||||
|
||||
} // namespace openspace::properties
|
||||
|
||||
@@ -43,9 +43,6 @@ public:
|
||||
int typeLua() const override;
|
||||
|
||||
using TemplateProperty<glm::vec3>::operator=;
|
||||
|
||||
protected:
|
||||
glm::vec3 fromLuaConversion(lua_State* state, bool& success) const override;
|
||||
};
|
||||
|
||||
} // namespace openspace::properties
|
||||
|
||||
@@ -43,9 +43,6 @@ public:
|
||||
int typeLua() const override;
|
||||
|
||||
using TemplateProperty<glm::vec4>::operator=;
|
||||
|
||||
protected:
|
||||
glm::vec4 fromLuaConversion(lua_State* state, bool& success) const override;
|
||||
};
|
||||
|
||||
} // namespace openspace::properties
|
||||
|
||||
@@ -41,10 +41,9 @@ int TransferFunctionProperty::typeLua() const {
|
||||
}
|
||||
|
||||
openspace::volume::TransferFunction
|
||||
TransferFunctionProperty::fromLuaConversion(lua_State* state, bool& success) const
|
||||
{
|
||||
TransferFunctionProperty::fromLuaConversion(lua_State* state) const {
|
||||
openspace::volume::TransferFunction tf;
|
||||
success = tf.setEnvelopesFromLua(state);
|
||||
tf.setEnvelopesFromLua(state);
|
||||
return tf;
|
||||
}
|
||||
|
||||
|
||||
@@ -41,8 +41,7 @@ public:
|
||||
using TemplateProperty<volume::TransferFunction>::operator=;
|
||||
|
||||
protected:
|
||||
volume::TransferFunction fromLuaConversion(lua_State* state,
|
||||
bool& success) const override;
|
||||
volume::TransferFunction fromLuaConversion(lua_State* state) const override;
|
||||
void toLuaConversion(lua_State* state) const override;
|
||||
std::string toStringConversion() const override;
|
||||
};
|
||||
|
||||
@@ -45,47 +45,6 @@ int DoubleListProperty::typeLua() const {
|
||||
return LUA_TTABLE;
|
||||
}
|
||||
|
||||
std::vector<double> DoubleListProperty::fromLuaConversion(lua_State* state,
|
||||
bool& success) const
|
||||
{
|
||||
if (!lua_istable(state, -1)) {
|
||||
success = false;
|
||||
LERRORC(className(), "Conversion from Lua failed. The input was not a table");
|
||||
return {};
|
||||
}
|
||||
|
||||
std::vector<double> result;
|
||||
lua_pushnil(state);
|
||||
while (lua_next(state, -2) != 0) {
|
||||
if (lua_isnumber(state, -1)) {
|
||||
result.emplace_back(lua_tonumber(state, -1));
|
||||
}
|
||||
else {
|
||||
success = false;
|
||||
LERRORC(
|
||||
className(),
|
||||
"Conversion from Lua failed. The input table contains non-number values"
|
||||
);
|
||||
return {};
|
||||
}
|
||||
lua_pop(state, 1);
|
||||
}
|
||||
success = true;
|
||||
return result;
|
||||
}
|
||||
|
||||
void DoubleListProperty::toLuaConversion(lua_State* state) const {
|
||||
lua_createtable(state, static_cast<int>(_value.size()), 0);
|
||||
|
||||
int i = 1;
|
||||
for (double v : _value) {
|
||||
ghoul::lua::push(state, i);
|
||||
ghoul::lua::push(state, v);
|
||||
lua_settable(state, -3);
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
||||
std::string DoubleListProperty::toStringConversion() const {
|
||||
nlohmann::json json(_value);
|
||||
return json.dump();
|
||||
|
||||
@@ -44,47 +44,6 @@ int IntListProperty::typeLua() const {
|
||||
return LUA_TTABLE;
|
||||
}
|
||||
|
||||
std::vector<int> IntListProperty::fromLuaConversion(lua_State* state,
|
||||
bool& success) const
|
||||
{
|
||||
if (!lua_istable(state, -1)) {
|
||||
success = false;
|
||||
LERRORC(className(), "Conversion from Lua failed. The input was not a table");
|
||||
return {};
|
||||
}
|
||||
|
||||
std::vector<int> result;
|
||||
lua_pushnil(state);
|
||||
while (lua_next(state, -2) != 0) {
|
||||
if (lua_isnumber(state, -1)) {
|
||||
result.emplace_back(static_cast<int>(lua_tonumber(state, -1)));
|
||||
}
|
||||
else {
|
||||
success = false;
|
||||
LERRORC(
|
||||
className(),
|
||||
"Conversion from Lua failed. The input table contains non-number values"
|
||||
);
|
||||
return {};
|
||||
}
|
||||
lua_pop(state, 1);
|
||||
}
|
||||
success = true;
|
||||
return result;
|
||||
}
|
||||
|
||||
void IntListProperty::toLuaConversion(lua_State* state) const {
|
||||
lua_createtable(state, static_cast<int>(_value.size()), 0);
|
||||
|
||||
int i = 1;
|
||||
for (int v : _value) {
|
||||
ghoul::lua::push(state, i);
|
||||
ghoul::lua::push(state, v);
|
||||
lua_settable(state, -3);
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
||||
std::string IntListProperty::toStringConversion() const {
|
||||
nlohmann::json json(_value);
|
||||
return json.dump();
|
||||
|
||||
@@ -45,43 +45,6 @@ int StringListProperty::typeLua() const {
|
||||
return LUA_TTABLE;
|
||||
}
|
||||
|
||||
std::vector<std::string> StringListProperty::fromLuaConversion(lua_State* state,
|
||||
bool& success) const
|
||||
{
|
||||
if (!lua_istable(state, -1)) {
|
||||
success = false;
|
||||
LERRORC(className(), "Conversion from Lua failed. The input was not a table");
|
||||
return {};
|
||||
}
|
||||
|
||||
std::vector<std::string> result;
|
||||
lua_pushnil(state);
|
||||
while (lua_next(state, -2) != 0) {
|
||||
if (lua_isstring(state, -1)) {
|
||||
result.emplace_back(lua_tostring(state, -1));
|
||||
}
|
||||
else {
|
||||
success = false;
|
||||
return {};
|
||||
}
|
||||
lua_pop(state, 1);
|
||||
}
|
||||
success = true;
|
||||
return result;
|
||||
}
|
||||
|
||||
void StringListProperty::toLuaConversion(lua_State* state) const {
|
||||
lua_createtable(state, static_cast<int>(_value.size()), 0);
|
||||
|
||||
int i = 1;
|
||||
for (const std::string& v : _value) {
|
||||
ghoul::lua::push(state, i);
|
||||
ghoul::lua::push(state, v.c_str());
|
||||
lua_settable(state, -3);
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
||||
std::string StringListProperty::toStringConversion() const {
|
||||
nlohmann::json json(_value);
|
||||
return json.dump();
|
||||
|
||||
@@ -49,8 +49,4 @@ int DMat2Property::typeLua() const {
|
||||
return LUA_TTABLE;
|
||||
}
|
||||
|
||||
glm::dmat2x2 DMat2Property::fromLuaConversion(lua_State* state, bool& success) const {
|
||||
return ghoul::lua::value<glm::dmat2x2>(state);
|
||||
}
|
||||
|
||||
} // namespace openspace::properties
|
||||
|
||||
@@ -49,8 +49,4 @@ int DMat3Property::typeLua() const {
|
||||
return LUA_TTABLE;
|
||||
}
|
||||
|
||||
glm::dmat3x3 DMat3Property::fromLuaConversion(lua_State* state, bool& success) const {
|
||||
return ghoul::lua::value<glm::mat3x3>(state);
|
||||
}
|
||||
|
||||
} // namespace openspace::properties
|
||||
|
||||
@@ -49,8 +49,4 @@ int DMat4Property::typeLua() const {
|
||||
return LUA_TTABLE;
|
||||
}
|
||||
|
||||
glm::dmat4x4 DMat4Property::fromLuaConversion(lua_State* state, bool& success) const {
|
||||
return ghoul::lua::value<glm::dmat4x4>(state);
|
||||
}
|
||||
|
||||
} // namespace openspace::properties
|
||||
|
||||
@@ -49,8 +49,4 @@ int Mat2Property::typeLua() const {
|
||||
return LUA_TTABLE;
|
||||
}
|
||||
|
||||
glm::mat2x2 Mat2Property::fromLuaConversion(lua_State* state, bool& success) const {
|
||||
return ghoul::lua::value<glm::mat2x2>(state);
|
||||
}
|
||||
|
||||
} // namespace openspace::properties
|
||||
|
||||
@@ -49,8 +49,4 @@ int Mat3Property::typeLua() const {
|
||||
return LUA_TTABLE;
|
||||
}
|
||||
|
||||
glm::mat3x3 Mat3Property::fromLuaConversion(lua_State* state, bool& success) const {
|
||||
return ghoul::lua::value<glm::mat3x3>(state);
|
||||
}
|
||||
|
||||
} // namespace openspace::properties
|
||||
|
||||
@@ -49,8 +49,4 @@ int Mat4Property::typeLua() const {
|
||||
return LUA_TTABLE;
|
||||
}
|
||||
|
||||
glm::mat4x4 Mat4Property::fromLuaConversion(lua_State* state, bool& success) const {
|
||||
return ghoul::lua::value<glm::mat4x4>(state);
|
||||
}
|
||||
|
||||
} // namespace openspace::properties
|
||||
|
||||
@@ -41,15 +41,6 @@ int BoolProperty::typeLua() const {
|
||||
return LUA_TBOOLEAN;
|
||||
}
|
||||
|
||||
bool BoolProperty::fromLuaConversion(lua_State* state, bool& success) const {
|
||||
success = (lua_isboolean(state, -1) == 1);
|
||||
return success ? (lua_toboolean(state, -1) == 1) : false;
|
||||
}
|
||||
|
||||
void BoolProperty::toLuaConversion(lua_State* state) const {
|
||||
ghoul::lua::push(state, _value);
|
||||
}
|
||||
|
||||
std::string BoolProperty::toStringConversion() const {
|
||||
return _value ? "true" : "false";
|
||||
}
|
||||
|
||||
@@ -41,15 +41,4 @@ int DoubleProperty::typeLua() const {
|
||||
return LUA_TNUMBER;
|
||||
}
|
||||
|
||||
double DoubleProperty::fromLuaConversion(lua_State* state, bool& success) const {
|
||||
success = (lua_isnumber(state, -1) == 1);
|
||||
if (success) {
|
||||
double val = lua_tonumber(state, -1);
|
||||
return val;
|
||||
}
|
||||
else {
|
||||
return 0.0;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace openspace::properties
|
||||
|
||||
@@ -41,15 +41,4 @@ int FloatProperty::typeLua() const {
|
||||
return LUA_TNUMBER;
|
||||
}
|
||||
|
||||
float FloatProperty::fromLuaConversion(lua_State* state, bool& success) const {
|
||||
success = (lua_isnumber(state, -1) == 1);
|
||||
if (success) {
|
||||
float val = static_cast<float>(lua_tonumber(state, -1));
|
||||
return val;
|
||||
}
|
||||
else {
|
||||
return 0.f;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace openspace::properties
|
||||
|
||||
@@ -41,15 +41,4 @@ int IntProperty::typeLua() const {
|
||||
return LUA_TNUMBER;
|
||||
}
|
||||
|
||||
int IntProperty::fromLuaConversion(lua_State* state, bool& success) const {
|
||||
success = (lua_isnumber(state, -1) == 1);
|
||||
if (success) {
|
||||
int val = static_cast<int>(lua_tonumber(state, -1));
|
||||
return val;
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace openspace::properties
|
||||
|
||||
@@ -41,15 +41,4 @@ int LongProperty::typeLua() const {
|
||||
return LUA_TNUMBER;
|
||||
}
|
||||
|
||||
long LongProperty::fromLuaConversion(lua_State* state, bool& success) const {
|
||||
success = (lua_isnumber(state, -1) == 1);
|
||||
if (success) {
|
||||
long val = static_cast<long>(lua_tonumber(state, -1));
|
||||
return val;
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace openspace::properties
|
||||
|
||||
@@ -41,15 +41,4 @@ int ShortProperty::typeLua() const {
|
||||
return LUA_TNUMBER;
|
||||
}
|
||||
|
||||
short ShortProperty::fromLuaConversion(lua_State* state, bool& success) const {
|
||||
success = (lua_isnumber(state, -1) == 1);
|
||||
if (success) {
|
||||
short val = static_cast<short>(lua_tonumber(state, -1));
|
||||
return val;
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace openspace::properties
|
||||
|
||||
@@ -48,15 +48,4 @@ int UIntProperty::typeLua() const {
|
||||
return LUA_TNUMBER;
|
||||
}
|
||||
|
||||
unsigned int UIntProperty::fromLuaConversion(lua_State* state, bool& success) const {
|
||||
success = (lua_isnumber(state, -1) == 1);
|
||||
if (success) {
|
||||
unsigned int val = static_cast<unsigned int>(lua_tonumber(state, -1));
|
||||
return val;
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace openspace::properties
|
||||
|
||||
@@ -48,15 +48,4 @@ int ULongProperty::typeLua() const {
|
||||
return LUA_TNUMBER;
|
||||
}
|
||||
|
||||
unsigned long ULongProperty::fromLuaConversion(lua_State* state, bool& success) const {
|
||||
success = (lua_isnumber(state, -1) == 1);
|
||||
if (success) {
|
||||
unsigned long val = static_cast<unsigned long>(lua_tonumber(state, -1));
|
||||
return val;
|
||||
}
|
||||
else {
|
||||
return 0ul;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace openspace::properties
|
||||
|
||||
@@ -48,15 +48,4 @@ int UShortProperty::typeLua() const {
|
||||
return LUA_TNUMBER;
|
||||
}
|
||||
|
||||
unsigned short UShortProperty::fromLuaConversion(lua_State* state, bool& success) const {
|
||||
success = (lua_isnumber(state, -1) == 1);
|
||||
if (success) {
|
||||
unsigned short val = static_cast<unsigned short>(lua_tonumber(state, -1));
|
||||
return val;
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace openspace::properties
|
||||
|
||||
@@ -129,44 +129,14 @@ void SelectionProperty::clearOptions() {
|
||||
clearSelection();
|
||||
}
|
||||
|
||||
std::set<std::string> SelectionProperty::fromLuaConversion(lua_State* state,
|
||||
bool& success) const
|
||||
{
|
||||
constexpr int KEY = -2;
|
||||
constexpr int VAL = -1;
|
||||
|
||||
if (!lua_istable(state, VAL)) {
|
||||
LERROR("Parameter passed to the property is not a table");
|
||||
success = false;
|
||||
return {};
|
||||
}
|
||||
|
||||
std::set<std::string> result;
|
||||
lua_pushnil(state);
|
||||
while (lua_next(state, KEY) != 0) {
|
||||
if (lua_isstring(state, VAL)) {
|
||||
result.insert(lua_tostring(state, -1));
|
||||
}
|
||||
else {
|
||||
success = false;
|
||||
return {};
|
||||
}
|
||||
lua_pop(state, 1);
|
||||
}
|
||||
|
||||
success = true;
|
||||
return result;
|
||||
std::set<std::string> SelectionProperty::fromLuaConversion(lua_State* state) const {
|
||||
std::vector<std::string> val = ghoul::lua::value<std::vector<std::string>>(state, -1);
|
||||
return std::set<std::string>(val.begin(), val.end());
|
||||
}
|
||||
|
||||
void SelectionProperty::toLuaConversion(lua_State* state) const {
|
||||
lua_newtable(state);
|
||||
int i = 1;
|
||||
for (const std::string& v : _value) {
|
||||
lua_pushinteger(state, i);
|
||||
lua_pushstring(state, v.c_str());
|
||||
lua_settable(state, -3);
|
||||
++i;
|
||||
}
|
||||
std::vector<std::string> value(_value.begin(), _value.end());
|
||||
ghoul::lua::push(state, value);
|
||||
}
|
||||
|
||||
std::string SelectionProperty::toStringConversion() const {
|
||||
|
||||
@@ -42,9 +42,8 @@ int StringProperty::typeLua() const {
|
||||
return LUA_TSTRING;
|
||||
}
|
||||
|
||||
std::string StringProperty::fromLuaConversion(lua_State* state, bool& success) const {
|
||||
success = lua_isstring(state, -1) == 1;
|
||||
return success ? lua_tostring(state, -1) : "";
|
||||
std::string StringProperty::fromLuaConversion(lua_State* state) const {
|
||||
return ghoul::lua::value<std::string>(state);
|
||||
}
|
||||
|
||||
void StringProperty::toLuaConversion(lua_State* state) const {
|
||||
|
||||
@@ -49,8 +49,4 @@ int DVec2Property::typeLua() const {
|
||||
return LUA_TTABLE;
|
||||
}
|
||||
|
||||
glm::dvec2 DVec2Property::fromLuaConversion(lua_State* state, bool& success) const {
|
||||
return ghoul::lua::value<glm::dvec2>(state);
|
||||
}
|
||||
|
||||
} // namespace openspace::properties
|
||||
|
||||
@@ -49,8 +49,4 @@ int DVec3Property::typeLua() const {
|
||||
return LUA_TTABLE;
|
||||
}
|
||||
|
||||
glm::dvec3 DVec3Property::fromLuaConversion(lua_State* state, bool& success) const {
|
||||
return ghoul::lua::value<glm::dvec3>(state);
|
||||
}
|
||||
|
||||
} // namespace openspace::properties
|
||||
|
||||
@@ -49,8 +49,4 @@ int DVec4Property::typeLua() const {
|
||||
return LUA_TTABLE;
|
||||
}
|
||||
|
||||
glm::dvec4 DVec4Property::fromLuaConversion(lua_State* state, bool& success) const {
|
||||
return ghoul::lua::value<glm::dvec4>(state);
|
||||
}
|
||||
|
||||
} // namespace openspace::properties
|
||||
|
||||
@@ -49,8 +49,4 @@ int IVec2Property::typeLua() const {
|
||||
return LUA_TTABLE;
|
||||
}
|
||||
|
||||
glm::ivec2 IVec2Property::fromLuaConversion(lua_State* state, bool& success) const {
|
||||
return ghoul::lua::value<glm::ivec2>(state);
|
||||
}
|
||||
|
||||
} // namespace openspace::properties
|
||||
|
||||
@@ -49,8 +49,4 @@ int IVec3Property::typeLua() const {
|
||||
return LUA_TTABLE;
|
||||
}
|
||||
|
||||
glm::ivec3 IVec3Property::fromLuaConversion(lua_State* state, bool& success) const {
|
||||
return ghoul::lua::value<glm::ivec3>(state);
|
||||
}
|
||||
|
||||
} // namespace openspace::properties
|
||||
|
||||
@@ -49,8 +49,4 @@ int IVec4Property::typeLua() const {
|
||||
return LUA_TTABLE;
|
||||
}
|
||||
|
||||
glm::ivec4 IVec4Property::fromLuaConversion(lua_State* state, bool& success) const {
|
||||
return ghoul::lua::value<glm::ivec4>(state);
|
||||
}
|
||||
|
||||
} // namespace openspace::properties
|
||||
|
||||
@@ -49,8 +49,4 @@ int UVec2Property::typeLua() const {
|
||||
return LUA_TTABLE;
|
||||
}
|
||||
|
||||
glm::uvec2 UVec2Property::fromLuaConversion(lua_State* state, bool& success) const {
|
||||
return ghoul::lua::value<glm::uvec2>(state);
|
||||
}
|
||||
|
||||
} // namespace openspace::properties
|
||||
|
||||
@@ -49,8 +49,4 @@ int UVec3Property::typeLua() const {
|
||||
return LUA_TTABLE;
|
||||
}
|
||||
|
||||
glm::uvec3 UVec3Property::fromLuaConversion(lua_State* state, bool& success) const {
|
||||
return ghoul::lua::value<glm::uvec3>(state);
|
||||
}
|
||||
|
||||
} // namespace openspace::properties
|
||||
|
||||
@@ -49,8 +49,4 @@ int UVec4Property::typeLua() const {
|
||||
return LUA_TTABLE;
|
||||
}
|
||||
|
||||
glm::uvec4 UVec4Property::fromLuaConversion(lua_State* state, bool& success) const {
|
||||
return ghoul::lua::value<glm::uvec4>(state);
|
||||
}
|
||||
|
||||
} // namespace openspace::properties
|
||||
|
||||
@@ -48,8 +48,4 @@ int Vec2Property::typeLua() const {
|
||||
return LUA_TTABLE;
|
||||
}
|
||||
|
||||
glm::vec2 Vec2Property::fromLuaConversion(lua_State* state, bool& success) const {
|
||||
return ghoul::lua::value<glm::vec2>(state);
|
||||
}
|
||||
|
||||
} // namespace openspace::properties
|
||||
|
||||
@@ -48,8 +48,4 @@ int Vec3Property::typeLua() const {
|
||||
return LUA_TTABLE;
|
||||
}
|
||||
|
||||
glm::vec3 Vec3Property::fromLuaConversion(lua_State* state, bool& success) const {
|
||||
return ghoul::lua::value<glm::vec3>(state);
|
||||
}
|
||||
|
||||
} // namespace openspace::properties
|
||||
|
||||
@@ -48,8 +48,4 @@ int Vec4Property::typeLua() const {
|
||||
return LUA_TTABLE;
|
||||
}
|
||||
|
||||
glm::vec4 Vec4Property::fromLuaConversion(lua_State* state, bool& success) const {
|
||||
return ghoul::lua::value<glm::vec4>(state);
|
||||
}
|
||||
|
||||
} // namespace openspace::properties
|
||||
|
||||
@@ -215,7 +215,6 @@ void applyRegularExpression(lua_State* L, const std::string& regex,
|
||||
// end of the loop, the property name regex was probably misspelled.
|
||||
bool foundMatching = false;
|
||||
for (properties::Property* prop : matchingProps) {
|
||||
|
||||
// Check that the types match
|
||||
if (type != prop->typeLua()) {
|
||||
LERRORC(
|
||||
@@ -233,6 +232,10 @@ void applyRegularExpression(lua_State* L, const std::string& regex,
|
||||
// value change if the types agree
|
||||
foundMatching = true;
|
||||
|
||||
// The setLuaInterpolationTarget and setLuaValue functions will remove the
|
||||
// value from the stack, so we need to push it to the end
|
||||
lua_pushvalue(L, -1);
|
||||
|
||||
if (global::sessionRecording->isRecording()) {
|
||||
global::sessionRecording->savePropertyBaseline(*prop);
|
||||
}
|
||||
|
||||
+1
-1
Submodule support/coding/codegen updated: 3ceac9b873...e72b9d7852
Reference in New Issue
Block a user