Browse Source

Trade: don't unwrap custom attribute/field names when passing to do*().

Originally I thought I'd save plugins some time if I just give them the
custom indices directly, without being wrapped in a SceneField /
MeshAttribute enum. But in practice that didn't really save anything,
made the interfaces more error-prone due to there being no concrete type
anymore, and all code that delegates to nested importers or converters
had to re-wrap the IDs again, which is *again* error-prone.

Bumping the interface strings because this is a breaking change for the
implementations. Not for users tho, there nothing changes.
pull/620/head
Vladimír Vondruš 3 years ago
parent
commit
509bad3462
  1. 21
      src/Magnum/SceneTools/Test/SceneConverterImplementationTest.cpp
  2. 8
      src/Magnum/SceneTools/sceneconverter.cpp
  3. 12
      src/Magnum/Trade/AbstractImporter.cpp
  4. 21
      src/Magnum/Trade/AbstractImporter.h
  5. 8
      src/Magnum/Trade/AbstractSceneConverter.cpp
  6. 13
      src/Magnum/Trade/AbstractSceneConverter.h
  7. 18
      src/Magnum/Trade/Test/AbstractImporterTest.cpp
  8. 28
      src/Magnum/Trade/Test/AbstractSceneConverterTest.cpp
  9. 8
      src/MagnumPlugins/AnySceneConverter/AnySceneConverter.cpp
  10. 4
      src/MagnumPlugins/AnySceneConverter/AnySceneConverter.h
  11. 8
      src/MagnumPlugins/AnySceneImporter/AnySceneImporter.cpp
  12. 4
      src/MagnumPlugins/AnySceneImporter/AnySceneImporter.h

21
src/Magnum/SceneTools/Test/SceneConverterImplementationTest.cpp

@ -224,8 +224,8 @@ void SceneConverterImplementationTest::infoScenesObjects() {
if(id == 8) return "Not in any scene"; if(id == 8) return "Not in any scene";
return ""; return "";
} }
Containers::String doSceneFieldName(UnsignedInt name) override { Containers::String doSceneFieldName(Trade::SceneField name) override {
if(name == 1337) return "DirectionVector"; if(name == Trade::sceneFieldCustom(1337)) return "DirectionVector";
return ""; return "";
} }
Containers::Optional<Trade::SceneData> doScene(UnsignedInt id) override { Containers::Optional<Trade::SceneData> doScene(UnsignedInt id) override {
@ -340,8 +340,8 @@ void SceneConverterImplementationTest::infoAnimations() {
CORRADE_INTERNAL_ASSERT_UNREACHABLE(); CORRADE_INTERNAL_ASSERT_UNREACHABLE();
} }
Containers::String doAnimationTrackTargetName(UnsignedShort name) override { Containers::String doAnimationTrackTargetName(Trade::AnimationTrackTarget name) override {
if(name == 333) if(name == Trade::animationTrackTargetCustom(333))
return "visibility"; return "visibility";
return {}; return {};
} }
@ -646,11 +646,11 @@ void SceneConverterImplementationTest::infoMeshes() {
Containers::String doMeshName(UnsignedInt id) override { Containers::String doMeshName(UnsignedInt id) override {
return id == 1 ? "LODs? No, meshets." : ""; return id == 1 ? "LODs? No, meshets." : "";
} }
Containers::String doMeshAttributeName(UnsignedShort name) override { Containers::String doMeshAttributeName(Trade::MeshAttribute name) override {
if(name == 25) return "vertices"; if(name == Trade::meshAttributeCustom(25)) return "vertices";
if(name == 26) return "triangles"; if(name == Trade::meshAttributeCustom(26)) return "triangles";
/* 37 (triangleCount) deliberately not named */ /* 37 (triangleCount) deliberately not named */
if(name == 116) return "vertexCount"; if(name == Trade::meshAttributeCustom(116)) return "vertexCount";
return ""; return "";
} }
@ -755,8 +755,9 @@ void SceneConverterImplementationTest::infoMeshesBounds() {
}}; }};
} }
Containers::String doMeshAttributeName(UnsignedShort name) override { Containers::String doMeshAttributeName(Trade::MeshAttribute name) override {
if(name == 25) return "NormalButCustomSoNoBoundsPrinted"; if(name == Trade::meshAttributeCustom(25))
return "NormalButCustomSoNoBoundsPrinted";
return ""; return "";
} }

8
src/Magnum/SceneTools/sceneconverter.cpp

@ -775,7 +775,7 @@ well, the IDs reference attributes of the first mesh.)")
if(!isMeshAttributeCustom(attributeName)) continue; if(!isMeshAttributeCustom(attributeName)) continue;
/* Appending even empty ones so we don't have to /* Appending even empty ones so we don't have to
special-case "not found" in doMeshAttributeName() */ special-case "not found" in doMeshAttributeName() */
arrayAppend(attributeNames, InPlaceInit, meshAttributeCustom(attributeName), original.meshAttributeName(attributeName)); arrayAppend(attributeNames, InPlaceInit, attributeName, original.meshAttributeName(attributeName));
} }
} }
@ -787,8 +787,8 @@ well, the IDs reference attributes of the first mesh.)")
Containers::String doMeshName(UnsignedInt) override { Containers::String doMeshName(UnsignedInt) override {
return name; return name;
} }
Containers::String doMeshAttributeName(UnsignedShort name) override { Containers::String doMeshAttributeName(Trade::MeshAttribute name) override {
for(const Containers::Pair<UnsignedShort, Containers::String>& i: attributeNames) for(const Containers::Pair<Trade::MeshAttribute, Containers::String>& i: attributeNames)
if(i.first() == name) return i.second(); if(i.first() == name) return i.second();
/* All custom attributes, including the unnamed, are in the /* All custom attributes, including the unnamed, are in the
attributeNames array and both our attribute name propagation attributeNames array and both our attribute name propagation
@ -803,7 +803,7 @@ well, the IDs reference attributes of the first mesh.)")
Trade::MeshData mesh; Trade::MeshData mesh;
Containers::String name; Containers::String name;
Containers::Array<Containers::Pair<UnsignedShort, Containers::String>> attributeNames; Containers::Array<Containers::Pair<Trade::MeshAttribute, Containers::String>> attributeNames;
}; };
/* Save the previous importer so we can pass it to the constructor in /* Save the previous importer so we can pass it to the constructor in

12
src/Magnum/Trade/AbstractImporter.cpp

@ -385,13 +385,13 @@ SceneField AbstractImporter::doSceneFieldForName(Containers::StringView) {
Containers::String AbstractImporter::sceneFieldName(const SceneField name) { Containers::String AbstractImporter::sceneFieldName(const SceneField name) {
CORRADE_ASSERT(isSceneFieldCustom(name), CORRADE_ASSERT(isSceneFieldCustom(name),
"Trade::AbstractImporter::sceneFieldName():" << name << "is not custom", {}); "Trade::AbstractImporter::sceneFieldName():" << name << "is not custom", {});
Containers::String out = doSceneFieldName(sceneFieldCustom(name)); Containers::String out = doSceneFieldName(name);
CORRADE_ASSERT(out.isSmall() || !out.deleter(), CORRADE_ASSERT(out.isSmall() || !out.deleter(),
"Trade::AbstractImporter::sceneFieldName(): implementation is not allowed to use a custom String deleter", {}); "Trade::AbstractImporter::sceneFieldName(): implementation is not allowed to use a custom String deleter", {});
return out; return out;
} }
Containers::String AbstractImporter::doSceneFieldName(UnsignedInt) { return {}; } Containers::String AbstractImporter::doSceneFieldName(SceneField) { return {}; }
UnsignedInt AbstractImporter::animationCount() const { UnsignedInt AbstractImporter::animationCount() const {
CORRADE_ASSERT(isOpened(), "Trade::AbstractImporter::animationCount(): no file opened", {}); CORRADE_ASSERT(isOpened(), "Trade::AbstractImporter::animationCount(): no file opened", {});
@ -462,13 +462,13 @@ AnimationTrackTarget AbstractImporter::doAnimationTrackTargetForName(Containers:
Containers::String AbstractImporter::animationTrackTargetName(const AnimationTrackTarget name) { Containers::String AbstractImporter::animationTrackTargetName(const AnimationTrackTarget name) {
CORRADE_ASSERT(isAnimationTrackTargetCustom(name), CORRADE_ASSERT(isAnimationTrackTargetCustom(name),
"Trade::AbstractImporter::animationTrackTargetName():" << name << "is not custom", {}); "Trade::AbstractImporter::animationTrackTargetName():" << name << "is not custom", {});
Containers::String out = doAnimationTrackTargetName(animationTrackTargetCustom(name)); Containers::String out = doAnimationTrackTargetName(name);
CORRADE_ASSERT(out.isSmall() || !out.deleter(), CORRADE_ASSERT(out.isSmall() || !out.deleter(),
"Trade::AbstractImporter::animationTrackTargetName(): implementation is not allowed to use a custom String deleter", {}); "Trade::AbstractImporter::animationTrackTargetName(): implementation is not allowed to use a custom String deleter", {});
return out; return out;
} }
Containers::String AbstractImporter::doAnimationTrackTargetName(UnsignedShort) { return {}; } Containers::String AbstractImporter::doAnimationTrackTargetName(AnimationTrackTarget) { return {}; }
UnsignedInt AbstractImporter::lightCount() const { UnsignedInt AbstractImporter::lightCount() const {
CORRADE_ASSERT(isOpened(), "Trade::AbstractImporter::lightCount(): no file opened", {}); CORRADE_ASSERT(isOpened(), "Trade::AbstractImporter::lightCount(): no file opened", {});
@ -1175,13 +1175,13 @@ MeshAttribute AbstractImporter::doMeshAttributeForName(Containers::StringView) {
Containers::String AbstractImporter::meshAttributeName(const MeshAttribute name) { Containers::String AbstractImporter::meshAttributeName(const MeshAttribute name) {
CORRADE_ASSERT(isMeshAttributeCustom(name), CORRADE_ASSERT(isMeshAttributeCustom(name),
"Trade::AbstractImporter::meshAttributeName():" << name << "is not custom", {}); "Trade::AbstractImporter::meshAttributeName():" << name << "is not custom", {});
Containers::String out = doMeshAttributeName(meshAttributeCustom(name)); Containers::String out = doMeshAttributeName(name);
CORRADE_ASSERT(out.isSmall() || !out.deleter(), CORRADE_ASSERT(out.isSmall() || !out.deleter(),
"Trade::AbstractImporter::meshAttributeName(): implementation is not allowed to use a custom String deleter", {}); "Trade::AbstractImporter::meshAttributeName(): implementation is not allowed to use a custom String deleter", {});
return out; return out;
} }
Containers::String AbstractImporter::doMeshAttributeName(UnsignedShort) { return {}; } Containers::String AbstractImporter::doMeshAttributeName(MeshAttribute) { return {}; }
#ifdef MAGNUM_BUILD_DEPRECATED #ifdef MAGNUM_BUILD_DEPRECATED
UnsignedInt AbstractImporter::mesh2DCount() const { UnsignedInt AbstractImporter::mesh2DCount() const {

21
src/Magnum/Trade/AbstractImporter.h

@ -1964,10 +1964,10 @@ class MAGNUM_TRADE_EXPORT AbstractImporter: public PluginManager::AbstractManagi
* @brief Implementation for @ref sceneFieldName() * @brief Implementation for @ref sceneFieldName()
* @m_since_latest * @m_since_latest
* *
* Receives the custom ID extracted via @ref sceneFieldCustom(SceneField). * The @p name is always custom. Default implementation returns an
* Default implementation returns an empty string. * empty string.
*/ */
virtual Containers::String doSceneFieldName(UnsignedInt name); virtual Containers::String doSceneFieldName(SceneField name);
/** /**
* @brief Implementation for @ref animationCount() * @brief Implementation for @ref animationCount()
@ -2008,11 +2008,10 @@ class MAGNUM_TRADE_EXPORT AbstractImporter: public PluginManager::AbstractManagi
* @brief Implementation for @ref animationTrackTargetName() * @brief Implementation for @ref animationTrackTargetName()
* @m_since_latest * @m_since_latest
* *
* Receives the custom ID extracted via * The @p name is always custom. Default implementation returns an
* @ref animationTrackTargetCustom(AnimationTrackTarget). Default * empty string.
* implementation returns an empty string.
*/ */
virtual Containers::String doAnimationTrackTargetName(UnsignedShort name); virtual Containers::String doAnimationTrackTargetName(AnimationTrackTarget name);
/** /**
* @brief Implementation for @ref lightCount() * @brief Implementation for @ref lightCount()
@ -2309,10 +2308,10 @@ class MAGNUM_TRADE_EXPORT AbstractImporter: public PluginManager::AbstractManagi
* @brief Implementation for @ref meshAttributeName() * @brief Implementation for @ref meshAttributeName()
* @m_since{2020,06} * @m_since{2020,06}
* *
* Receives the custom ID extracted via @ref meshAttributeCustom(MeshAttribute). * The @p name is always custom. Default implementation returns an
* Default implementation returns an empty string. * empty string.
*/ */
virtual Containers::String doMeshAttributeName(UnsignedShort name); virtual Containers::String doMeshAttributeName(MeshAttribute name);
#ifdef MAGNUM_BUILD_DEPRECATED #ifdef MAGNUM_BUILD_DEPRECATED
/** /**
@ -2637,7 +2636,7 @@ updated interface string.
*/ */
/* Silly indentation to make the string appear in pluginInterface() docs */ /* Silly indentation to make the string appear in pluginInterface() docs */
#define MAGNUM_TRADE_ABSTRACTIMPORTER_PLUGIN_INTERFACE /* [interface] */ \ #define MAGNUM_TRADE_ABSTRACTIMPORTER_PLUGIN_INTERFACE /* [interface] */ \
"cz.mosra.magnum.Trade.AbstractImporter/0.5.1" "cz.mosra.magnum.Trade.AbstractImporter/0.5.2"
/* [interface] */ /* [interface] */
#ifndef DOXYGEN_GENERATING_OUTPUT #ifndef DOXYGEN_GENERATING_OUTPUT

8
src/Magnum/Trade/AbstractSceneConverter.cpp

@ -622,10 +622,10 @@ void AbstractSceneConverter::setSceneFieldName(const SceneField field, const Con
CORRADE_ASSERT(isSceneFieldCustom(field), CORRADE_ASSERT(isSceneFieldCustom(field),
"Trade::AbstractSceneConverter::setSceneFieldName():" << field << "is not custom", ); "Trade::AbstractSceneConverter::setSceneFieldName():" << field << "is not custom", );
doSetSceneFieldName(sceneFieldCustom(field), name); doSetSceneFieldName(field, name);
} }
void AbstractSceneConverter::doSetSceneFieldName(UnsignedInt, Containers::StringView) {} void AbstractSceneConverter::doSetSceneFieldName(SceneField, Containers::StringView) {}
void AbstractSceneConverter::setObjectName(const UnsignedLong object, const Containers::StringView name) { void AbstractSceneConverter::setObjectName(const UnsignedLong object, const Containers::StringView name) {
CORRADE_ASSERT(features() & SceneConverterFeature::AddScenes, CORRADE_ASSERT(features() & SceneConverterFeature::AddScenes,
@ -849,10 +849,10 @@ void AbstractSceneConverter::setMeshAttributeName(const MeshAttribute attribute,
CORRADE_ASSERT(isMeshAttributeCustom(attribute), CORRADE_ASSERT(isMeshAttributeCustom(attribute),
"Trade::AbstractSceneConverter::setMeshAttributeName():" << attribute << "is not custom", ); "Trade::AbstractSceneConverter::setMeshAttributeName():" << attribute << "is not custom", );
doSetMeshAttributeName(meshAttributeCustom(attribute), name); doSetMeshAttributeName(attribute, name);
} }
void AbstractSceneConverter::doSetMeshAttributeName(UnsignedShort, Containers::StringView) {} void AbstractSceneConverter::doSetMeshAttributeName(MeshAttribute, Containers::StringView) {}
UnsignedInt AbstractSceneConverter::materialCount() const { UnsignedInt AbstractSceneConverter::materialCount() const {
CORRADE_ASSERT(_state, "Trade::AbstractSceneConverter::materialCount(): no conversion in progress", {}); CORRADE_ASSERT(_state, "Trade::AbstractSceneConverter::materialCount(): no conversion in progress", {});

13
src/Magnum/Trade/AbstractSceneConverter.h

@ -2197,11 +2197,9 @@ class MAGNUM_TRADE_EXPORT AbstractSceneConverter: public PluginManager::Abstract
* @brief Implementation for @ref setSceneFieldName() * @brief Implementation for @ref setSceneFieldName()
* @m_since_latest * @m_since_latest
* *
* Receives the custom ID extracted via * The @p field is always custom. Default implementation does nothing.
* @ref sceneFieldCustom(SceneField). Default implementation does
* nothing.
*/ */
virtual void doSetSceneFieldName(UnsignedInt field, Containers::StringView name); virtual void doSetSceneFieldName(SceneField field, Containers::StringView name);
/** /**
* @brief Implementation for @ref setObjectName() * @brief Implementation for @ref setObjectName()
@ -2308,11 +2306,10 @@ class MAGNUM_TRADE_EXPORT AbstractSceneConverter: public PluginManager::Abstract
* @brief Implementation for @ref setMeshAttributeName() * @brief Implementation for @ref setMeshAttributeName()
* @m_since_latest * @m_since_latest
* *
* Receives the custom ID extracted via * The @p attribute is always custom. Default implementation does
* @ref meshAttributeCustom(MeshAttribute). Default implementation does
* nothing. * nothing.
*/ */
virtual void doSetMeshAttributeName(UnsignedShort attribute, Containers::StringView name); virtual void doSetMeshAttributeName(MeshAttribute attribute, Containers::StringView name);
/** /**
* @brief Implementation for @ref add(const MaterialData&, Containers::StringView) * @brief Implementation for @ref add(const MaterialData&, Containers::StringView)
@ -2441,7 +2438,7 @@ updated interface string.
*/ */
/* Silly indentation to make the string appear in pluginInterface() docs */ /* Silly indentation to make the string appear in pluginInterface() docs */
#define MAGNUM_TRADE_ABSTRACTSCENECONVERTER_PLUGIN_INTERFACE /* [interface] */ \ #define MAGNUM_TRADE_ABSTRACTSCENECONVERTER_PLUGIN_INTERFACE /* [interface] */ \
"cz.mosra.magnum.Trade.AbstractSceneConverter/0.2.1" "cz.mosra.magnum.Trade.AbstractSceneConverter/0.2.2"
/* [interface] */ /* [interface] */
}} }}

18
src/Magnum/Trade/Test/AbstractImporterTest.cpp

@ -3771,8 +3771,8 @@ void AbstractImporterTest::sceneFieldName() {
return SceneField{}; return SceneField{};
} }
Containers::String doSceneFieldName(UnsignedInt id) override { Containers::String doSceneFieldName(SceneField id) override {
if(id == 100037) return "OctreeCell"; if(id == sceneFieldCustom(100037)) return "OctreeCell";
return ""; return "";
} }
} importer; } importer;
@ -3822,7 +3822,7 @@ void AbstractImporterTest::sceneFieldNameCustomDeleter() {
bool doIsOpened() const override { return true; } bool doIsOpened() const override { return true; }
void doClose() override {} void doClose() override {}
Containers::String doSceneFieldName(UnsignedInt) override { Containers::String doSceneFieldName(SceneField) override {
return Containers::String{"a", 1, [](char*, std::size_t) {}}; return Containers::String{"a", 1, [](char*, std::size_t) {}};
} }
} importer; } importer;
@ -4098,8 +4098,8 @@ void AbstractImporterTest::animationTrackTargetName() {
return AnimationTrackTarget{}; return AnimationTrackTarget{};
} }
Containers::String doAnimationTrackTargetName(UnsignedShort id) override { Containers::String doAnimationTrackTargetName(AnimationTrackTarget id) override {
if(id == 37) return "visibility"; if(id == animationTrackTargetCustom(37)) return "visibility";
return ""; return "";
} }
} importer; } importer;
@ -4149,7 +4149,7 @@ void AbstractImporterTest::animationTrackTargetNameCustomDeleter() {
bool doIsOpened() const override { return true; } bool doIsOpened() const override { return true; }
void doClose() override {} void doClose() override {}
Containers::String doAnimationTrackTargetName(UnsignedShort) override { Containers::String doAnimationTrackTargetName(AnimationTrackTarget) override {
return Containers::String{"a", 1, [](char*, std::size_t) {}}; return Containers::String{"a", 1, [](char*, std::size_t) {}};
} }
} importer; } importer;
@ -5911,8 +5911,8 @@ void AbstractImporterTest::meshAttributeName() {
return MeshAttribute{}; return MeshAttribute{};
} }
Containers::String doMeshAttributeName(UnsignedShort id) override { Containers::String doMeshAttributeName(MeshAttribute id) override {
if(id == 37) return "SMOOTH_GROUP_ID"; if(id == meshAttributeCustom(37)) return "SMOOTH_GROUP_ID";
return ""; return "";
} }
} importer; } importer;
@ -5962,7 +5962,7 @@ void AbstractImporterTest::meshAttributeNameCustomDeleter() {
bool doIsOpened() const override { return true; } bool doIsOpened() const override { return true; }
void doClose() override {} void doClose() override {}
Containers::String doMeshAttributeName(UnsignedShort) override { Containers::String doMeshAttributeName(MeshAttribute) override {
return Containers::String{"a", 1, [](char*, std::size_t) {}}; return Containers::String{"a", 1, [](char*, std::size_t) {}};
} }
} importer; } importer;

28
src/Magnum/Trade/Test/AbstractSceneConverterTest.cpp

@ -2823,8 +2823,8 @@ void AbstractSceneConverterTest::setSceneFieldName() {
bool doBegin() override { return true; } bool doBegin() override { return true; }
void doSetSceneFieldName(UnsignedInt field, Containers::StringView name) override { void doSetSceneFieldName(SceneField field, Containers::StringView name) override {
CORRADE_COMPARE(field, 1337); CORRADE_COMPARE(field, sceneFieldCustom(1337));
CORRADE_COMPARE(name, "hello!"); CORRADE_COMPARE(name, "hello!");
setSceneFieldNameCalled = true; setSceneFieldNameCalled = true;
} }
@ -4122,8 +4122,8 @@ void AbstractSceneConverterTest::setMeshAttributeName() {
bool doBegin() override { return true; } bool doBegin() override { return true; }
void doSetMeshAttributeName(UnsignedShort field, Containers::StringView name) override { void doSetMeshAttributeName(MeshAttribute field, Containers::StringView name) override {
CORRADE_COMPARE(field, 1337); CORRADE_COMPARE(field, meshAttributeCustom(1337));
CORRADE_COMPARE(name, "hello!"); CORRADE_COMPARE(name, "hello!");
setMeshAttributeNameCalled = true; setMeshAttributeNameCalled = true;
} }
@ -6215,9 +6215,9 @@ void AbstractSceneConverterTest::addImporterContentsCustomSceneFields() {
}}; }};
return SceneData{SceneMappingType::UnsignedInt, 0, nullptr, {}}; return SceneData{SceneMappingType::UnsignedInt, 0, nullptr, {}};
} }
Containers::String doSceneFieldName(UnsignedInt name) override { Containers::String doSceneFieldName(SceneField name) override {
if(name == 34977) return "OffsetSmall"; if(name == sceneFieldCustom(34977)) return "OffsetSmall";
if(name == 5266) return "ValueData"; if(name == sceneFieldCustom(5266)) return "ValueData";
CORRADE_FAIL("This should not be reached"); CORRADE_FAIL("This should not be reached");
CORRADE_INTERNAL_ASSERT_UNREACHABLE(); CORRADE_INTERNAL_ASSERT_UNREACHABLE();
} }
@ -6236,8 +6236,8 @@ void AbstractSceneConverterTest::addImporterContentsCustomSceneFields() {
Debug{} << "Adding scene"; Debug{} << "Adding scene";
return true; return true;
} }
void doSetSceneFieldName(UnsignedInt field, Containers::StringView name) override { void doSetSceneFieldName(SceneField field, Containers::StringView name) override {
Debug{} << "Setting field" << field << "name to" << name; Debug{} << "Setting field" << sceneFieldCustom(field) << "name to" << name;
} }
} converter; } converter;
@ -6280,9 +6280,9 @@ void AbstractSceneConverterTest::addImporterContentsCustomMeshAttributes() {
}}; }};
return MeshData{MeshPrimitive::Points, 0}; return MeshData{MeshPrimitive::Points, 0};
} }
Containers::String doMeshAttributeName(UnsignedShort name) override { Containers::String doMeshAttributeName(MeshAttribute name) override {
if(name == 31977) return "OffsetSmall"; if(name == meshAttributeCustom(31977)) return "OffsetSmall";
if(name == 5266) return "ValueData"; if(name == meshAttributeCustom(5266)) return "ValueData";
CORRADE_FAIL("This should not be reached"); CORRADE_FAIL("This should not be reached");
CORRADE_INTERNAL_ASSERT_UNREACHABLE(); CORRADE_INTERNAL_ASSERT_UNREACHABLE();
} }
@ -6302,8 +6302,8 @@ void AbstractSceneConverterTest::addImporterContentsCustomMeshAttributes() {
Debug{} << "Adding mesh levels"; Debug{} << "Adding mesh levels";
return true; return true;
} }
void doSetMeshAttributeName(UnsignedShort attribute, Containers::StringView name) override { void doSetMeshAttributeName(MeshAttribute attribute, Containers::StringView name) override {
Debug{} << "Setting attribute" << attribute << "name to" << name; Debug{} << "Setting attribute" << meshAttributeCustom(attribute) << "name to" << name;
} }
} converter; } converter;

8
src/MagnumPlugins/AnySceneConverter/AnySceneConverter.cpp

@ -191,8 +191,8 @@ bool AnySceneConverter::doAdd(CORRADE_UNUSED const UnsignedInt id, const SceneDa
return !!_converter->add(scene, name); return !!_converter->add(scene, name);
} }
void AnySceneConverter::doSetSceneFieldName(const UnsignedInt field, const Containers::StringView name) { void AnySceneConverter::doSetSceneFieldName(const SceneField field, const Containers::StringView name) {
return _converter->setSceneFieldName(sceneFieldCustom(field), name); return _converter->setSceneFieldName(field, name);
} }
void AnySceneConverter::doSetObjectName(const UnsignedLong object, const Containers::StringView name) { void AnySceneConverter::doSetObjectName(const UnsignedLong object, const Containers::StringView name) {
@ -238,8 +238,8 @@ bool AnySceneConverter::doAdd(CORRADE_UNUSED const UnsignedInt id, const Contain
return !!_converter->add(meshLevels, name); return !!_converter->add(meshLevels, name);
} }
void AnySceneConverter::doSetMeshAttributeName(const UnsignedShort attribute, const Containers::StringView name) { void AnySceneConverter::doSetMeshAttributeName(const MeshAttribute attribute, const Containers::StringView name) {
return _converter->setMeshAttributeName(meshAttributeCustom(attribute), name); return _converter->setMeshAttributeName(attribute, name);
} }
bool AnySceneConverter::doAdd(CORRADE_UNUSED const UnsignedInt id, const MaterialData& material, const Containers::StringView name) { bool AnySceneConverter::doAdd(CORRADE_UNUSED const UnsignedInt id, const MaterialData& material, const Containers::StringView name) {

4
src/MagnumPlugins/AnySceneConverter/AnySceneConverter.h

@ -146,7 +146,7 @@ class MAGNUM_ANYSCENECONVERTER_EXPORT AnySceneConverter: public AbstractSceneCon
bool doEndFile(Containers::StringView filename) override; bool doEndFile(Containers::StringView filename) override;
bool doAdd(UnsignedInt id, const SceneData& scene, Containers::StringView name) override; bool doAdd(UnsignedInt id, const SceneData& scene, Containers::StringView name) override;
void doSetSceneFieldName(UnsignedInt field, Containers::StringView name) override; void doSetSceneFieldName(SceneField field, Containers::StringView name) override;
void doSetObjectName(UnsignedLong object, Containers::StringView name) override; void doSetObjectName(UnsignedLong object, Containers::StringView name) override;
void doSetDefaultScene(UnsignedInt id) override; void doSetDefaultScene(UnsignedInt id) override;
@ -158,7 +158,7 @@ class MAGNUM_ANYSCENECONVERTER_EXPORT AnySceneConverter: public AbstractSceneCon
bool doAdd(UnsignedInt id, const MeshData& mesh, Containers::StringView name) override; bool doAdd(UnsignedInt id, const MeshData& mesh, Containers::StringView name) override;
bool doAdd(UnsignedInt id, const Containers::Iterable<const MeshData>& meshLevels, Containers::StringView name) override; bool doAdd(UnsignedInt id, const Containers::Iterable<const MeshData>& meshLevels, Containers::StringView name) override;
void doSetMeshAttributeName(UnsignedShort attribute, Containers::StringView name) override; void doSetMeshAttributeName(MeshAttribute attribute, Containers::StringView name) override;
bool doAdd(UnsignedInt id, const MaterialData& material, Containers::StringView name) override; bool doAdd(UnsignedInt id, const MaterialData& material, Containers::StringView name) override;
bool doAdd(UnsignedInt id, const TextureData& texture, Containers::StringView name) override; bool doAdd(UnsignedInt id, const TextureData& texture, Containers::StringView name) override;

8
src/MagnumPlugins/AnySceneImporter/AnySceneImporter.cpp

@ -200,10 +200,10 @@ SceneField AnySceneImporter::doSceneFieldForName(const Containers::StringView na
an invalid ID */ an invalid ID */
return _in ? _in->sceneFieldForName(name) : SceneField{}; return _in ? _in->sceneFieldForName(name) : SceneField{};
} }
Containers::String AnySceneImporter::doSceneFieldName(const UnsignedInt name) { Containers::String AnySceneImporter::doSceneFieldName(const SceneField name) {
/* This API can be called even if no file is opened, in that case return /* This API can be called even if no file is opened, in that case return
an invalid ID */ an invalid ID */
return _in ? _in->sceneFieldName(sceneFieldCustom(name)) : Containers::String{}; return _in ? _in->sceneFieldName(name) : Containers::String{};
} }
UnsignedInt AnySceneImporter::doLightCount() const { return _in->lightCount(); } UnsignedInt AnySceneImporter::doLightCount() const { return _in->lightCount(); }
@ -250,10 +250,10 @@ MeshAttribute AnySceneImporter::doMeshAttributeForName(const Containers::StringV
an invalid ID */ an invalid ID */
return _in ? _in->meshAttributeForName(name) : MeshAttribute{}; return _in ? _in->meshAttributeForName(name) : MeshAttribute{};
} }
Containers::String AnySceneImporter::doMeshAttributeName(const UnsignedShort id) { Containers::String AnySceneImporter::doMeshAttributeName(const MeshAttribute id) {
/* This API can be called even if no file is opened, in that case return /* This API can be called even if no file is opened, in that case return
an invalid ID */ an invalid ID */
return _in ? _in->meshAttributeName(meshAttributeCustom(id)) : Containers::String{}; return _in ? _in->meshAttributeName(id) : Containers::String{};
} }
#ifdef MAGNUM_BUILD_DEPRECATED #ifdef MAGNUM_BUILD_DEPRECATED

4
src/MagnumPlugins/AnySceneImporter/AnySceneImporter.h

@ -194,7 +194,7 @@ class MAGNUM_ANYSCENEIMPORTER_EXPORT AnySceneImporter: public AbstractImporter {
MAGNUM_ANYSCENEIMPORTER_LOCAL Containers::String doObjectName(UnsignedLong id) override; MAGNUM_ANYSCENEIMPORTER_LOCAL Containers::String doObjectName(UnsignedLong id) override;
MAGNUM_ANYSCENEIMPORTER_LOCAL Containers::Optional<SceneData> doScene(UnsignedInt id) override; MAGNUM_ANYSCENEIMPORTER_LOCAL Containers::Optional<SceneData> doScene(UnsignedInt id) override;
MAGNUM_ANYSCENEIMPORTER_LOCAL SceneField doSceneFieldForName(Containers::StringView name) override; MAGNUM_ANYSCENEIMPORTER_LOCAL SceneField doSceneFieldForName(Containers::StringView name) override;
MAGNUM_ANYSCENEIMPORTER_LOCAL Containers::String doSceneFieldName(Magnum::UnsignedInt name) override; MAGNUM_ANYSCENEIMPORTER_LOCAL Containers::String doSceneFieldName(SceneField name) override;
MAGNUM_ANYSCENEIMPORTER_LOCAL UnsignedInt doLightCount() const override; MAGNUM_ANYSCENEIMPORTER_LOCAL UnsignedInt doLightCount() const override;
MAGNUM_ANYSCENEIMPORTER_LOCAL Int doLightForName(Containers::StringView name) override; MAGNUM_ANYSCENEIMPORTER_LOCAL Int doLightForName(Containers::StringView name) override;
@ -238,7 +238,7 @@ class MAGNUM_ANYSCENEIMPORTER_EXPORT AnySceneImporter: public AbstractImporter {
MAGNUM_ANYSCENEIMPORTER_LOCAL Containers::Optional<MeshData> doMesh(UnsignedInt id, UnsignedInt level) override; MAGNUM_ANYSCENEIMPORTER_LOCAL Containers::Optional<MeshData> doMesh(UnsignedInt id, UnsignedInt level) override;
MAGNUM_ANYSCENEIMPORTER_LOCAL MeshAttribute doMeshAttributeForName(Containers::StringView name) override; MAGNUM_ANYSCENEIMPORTER_LOCAL MeshAttribute doMeshAttributeForName(Containers::StringView name) override;
MAGNUM_ANYSCENEIMPORTER_LOCAL Containers::String doMeshAttributeName(UnsignedShort id) override; MAGNUM_ANYSCENEIMPORTER_LOCAL Containers::String doMeshAttributeName(MeshAttribute id) override;
#ifdef MAGNUM_BUILD_DEPRECATED #ifdef MAGNUM_BUILD_DEPRECATED
MAGNUM_ANYSCENEIMPORTER_LOCAL UnsignedInt doMesh2DCount() const override; MAGNUM_ANYSCENEIMPORTER_LOCAL UnsignedInt doMesh2DCount() const override;

Loading…
Cancel
Save