Skip to content

Commit

Permalink
Revert "--ConfigValue Updates - Matrix4 support, pointer-backed data …
Browse files Browse the repository at this point in the history
…store. (…" (#2367)

This reverts commit accdbbd.
  • Loading branch information
jturner65 authored Apr 23, 2024
1 parent accdbbd commit cb39437
Show file tree
Hide file tree
Showing 10 changed files with 240 additions and 422 deletions.
61 changes: 26 additions & 35 deletions src/esp/bindings/ConfigBindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,48 +14,45 @@ namespace config {

py::object getObjectForConfigValue(const ConfigValue& value) {
switch (value.getType()) {
case ConfigValType::Unknown:
case ConfigStoredType::Unknown:
return py::cast(nullptr);
case ConfigValType::Boolean:
case ConfigStoredType::Boolean:
return py::cast(value.get<bool>());
case ConfigValType::Integer:
case ConfigStoredType::Integer:
return py::cast(value.get<int>());
case ConfigValType::Double:
case ConfigStoredType::Double:
return py::cast(value.get<double>());
case ConfigValType::String:
case ConfigStoredType::String:
return py::cast(value.get<std::string>());
case ConfigValType::MagnumVec2:
case ConfigStoredType::MagnumVec2:
return py::cast(value.get<Mn::Vector2>());
case ConfigValType::MagnumVec3:
case ConfigStoredType::MagnumVec3:
return py::cast(value.get<Mn::Vector3>());
case ConfigValType::MagnumVec4:
case ConfigStoredType::MagnumVec4:
return py::cast(value.get<Mn::Vector4>());
case ConfigValType::MagnumMat3:
case ConfigStoredType::MagnumMat3:
return py::cast(value.get<Mn::Matrix3>());
case ConfigValType::MagnumMat4:
return py::cast(value.get<Mn::Matrix4>());
case ConfigValType::MagnumQuat:
case ConfigStoredType::MagnumQuat:
return py::cast(value.get<Mn::Quaternion>());
case ConfigValType::MagnumRad:
case ConfigStoredType::MagnumRad:
return py::cast(value.get<Mn::Rad>());
}
return py::cast(nullptr);
}

void initConfigBindings(py::module& m) {
py::enum_<ConfigValType>(m, "ConfigValType")
.value("Unknown", ConfigValType::Unknown)
.value("Boolean", ConfigValType::Boolean)
.value("Integer", ConfigValType::Integer)
.value("Float", ConfigValType::Double)
.value("String", ConfigValType::String)
.value("MagnumVec2", ConfigValType::MagnumVec2)
.value("MagnumVec3", ConfigValType::MagnumVec3)
.value("MagnumVec4", ConfigValType::MagnumVec4)
.value("MagnumMat3", ConfigValType::MagnumMat3)
.value("MagnumMat4", ConfigValType::MagnumMat4)
.value("MagnumQuat", ConfigValType::MagnumQuat)
.value("MagnumRad", ConfigValType::MagnumRad);
py::enum_<ConfigStoredType>(m, "ConfigStoredType")
.value("Unknown", ConfigStoredType::Unknown)
.value("Boolean", ConfigStoredType::Boolean)
.value("Integer", ConfigStoredType::Integer)
.value("Float", ConfigStoredType::Double)
.value("String", ConfigStoredType::String)
.value("MagnumVec2", ConfigStoredType::MagnumVec2)
.value("MagnumVec3", ConfigStoredType::MagnumVec3)
.value("MagnumVec4", ConfigStoredType::MagnumVec4)
.value("MagnumMat3", ConfigStoredType::MagnumMat3)
.value("MagnumQuat", ConfigStoredType::MagnumQuat)
.value("MagnumRad", ConfigStoredType::MagnumRad);

py::class_<Configuration, Configuration::ptr>(m, "Configuration")
.def(py::init(&Configuration::create<>))
Expand Down Expand Up @@ -131,23 +128,17 @@ void initConfigBindings(py::module& m) {
const Magnum::Matrix3& val) { self.set(key, val); },
R"(Set the value specified by given string key to be specified Magnum::Matrix3 value)",
"key"_a, "value"_a)
.def(
"set",
[](Configuration& self, const std::string& key,
const Magnum::Matrix4& val) { self.set(key, val); },
R"(Set the value specified by given string key to be specified Magnum::Matrix4 value)",
"key"_a, "value"_a)
.def(
"get_type", &Configuration::getType,
R"(Retrieves the ConfigValType of the value referred to by the passed key.)")
R"(Retrieves the ConfigStoredType of the value referred to by the passed key.)")

.def(
"get_as_string", &Configuration::getAsString,
R"(Retrieves a string representation of the value referred to by the passed key.)")

.def(
"get_keys_by_type", &Configuration::getStoredKeys,
R"(Retrieves a list of all the keys of values of the specified types. Takes ConfigValType
R"(Retrieves a list of all the keys of values of the specified types. Takes ConfigStoredType
enum value as argument.)",
"value_type"_a)

Expand All @@ -167,7 +158,7 @@ void initConfigBindings(py::module& m) {
"key"_a)
.def(
"has_key_to_type", &Configuration::hasKeyOfType,
R"(Returns whether passed key points to a value of specified ConfigValType)",
R"(Returns whether passed key points to a value of specified ConfigStoredType)",
"key"_a, "value_type"_a)
.def(
"remove",
Expand Down
Loading

0 comments on commit cb39437

Please sign in to comment.