Merge pull request #4596 from assimp/kimkulling/fix_invalid_opengex_token_match

Kimkulling/fix invalid opengex token match
pull/4598/head
Kim Kulling 2022-06-28 20:59:37 +02:00 committed by GitHub
commit e1e8477732
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 28 additions and 38 deletions

View File

@ -151,45 +151,46 @@ namespace Grammar {
}
static TokenType matchTokenType(const char *tokenType) {
if (MetricType == tokenType) {
const size_t len = std::strlen(tokenType);
if (0 == strncmp(MetricType, tokenType, len)) {
return MetricToken;
} else if (NameType == tokenType) {
} else if (0 == strncmp(NameType, tokenType, len)) {
return NameToken;
} else if (ObjectRefType == tokenType) {
} else if (0 == strncmp(ObjectRefType, tokenType, len)) {
return ObjectRefToken;
} else if (MaterialRefType == tokenType) {
} else if (0 == strncmp(MaterialRefType, tokenType, len)) {
return MaterialRefToken;
} else if (MetricKeyType == tokenType) {
} else if (0 == strncmp(MetricKeyType, tokenType, len)) {
return MetricKeyToken;
} else if (GeometryNodeType == tokenType) {
} else if (0 == strncmp(GeometryNodeType, tokenType, len)) {
return GeometryNodeToken;
} else if (CameraNodeType == tokenType) {
} else if (0 == strncmp(CameraNodeType, tokenType, len)) {
return CameraNodeToken;
} else if (LightNodeType == tokenType) {
} else if (0 == strncmp(LightNodeType, tokenType, len)) {
return LightNodeToken;
} else if (GeometryObjectType == tokenType) {
} else if (0 == strncmp(GeometryObjectType, tokenType, len)) {
return GeometryObjectToken;
} else if (CameraObjectType == tokenType) {
} else if (0 == strncmp(CameraObjectType, tokenType, len)) {
return CameraObjectToken;
} else if (LightObjectType == tokenType) {
} else if (0 == strncmp(LightObjectType, tokenType, len)) {
return LightObjectToken;
} else if (TransformType == tokenType) {
} else if (0 == strncmp(TransformType, tokenType, len)) {
return TransformToken;
} else if (MeshType == tokenType) {
} else if (0 == strncmp(MeshType, tokenType, len)) {
return MeshToken;
} else if (VertexArrayType == tokenType) {
} else if (0 == strncmp(VertexArrayType, tokenType, len)) {
return VertexArrayToken;
} else if (IndexArrayType == tokenType) {
} else if (0 == strncmp(IndexArrayType, tokenType, len)) {
return IndexArrayToken;
} else if (MaterialType == tokenType) {
} else if (0 == strncmp(MaterialType, tokenType, len)) {
return MaterialToken;
} else if (ColorType == tokenType) {
} else if (0 == strncmp(ColorType, tokenType, len)) {
return ColorToken;
} else if (ParamType == tokenType) {
} else if (0 == strncmp(ParamType, tokenType, len)) {
return ParamToken;
} else if (TextureType == tokenType) {
} else if (0 == strncmp(TextureType, tokenType, len)) {
return TextureToken;
} else if (AttenType == tokenType) {
} else if (0 == strncmp(AttenType, tokenType, len)) {
return AttenToken;
}
@ -256,11 +257,6 @@ OpenGEXImporter::RefInfo::RefInfo(aiNode *node, Type type, std::vector<std::stri
// empty
}
//------------------------------------------------------------------------------------------------
OpenGEXImporter::RefInfo::~RefInfo() {
// empty
}
//------------------------------------------------------------------------------------------------
OpenGEXImporter::OpenGEXImporter() :
m_root(nullptr),
@ -285,10 +281,6 @@ OpenGEXImporter::OpenGEXImporter() :
// empty
}
//------------------------------------------------------------------------------------------------
OpenGEXImporter::~OpenGEXImporter() {
}
//------------------------------------------------------------------------------------------------
bool OpenGEXImporter::CanRead(const std::string &file, IOSystem *pIOHandler, bool /*checkSig*/) const {
static const char *tokens[] = { "Metric", "GeometryNode", "VertexArray (attrib", "IndexArray" };

View File

@ -79,12 +79,7 @@ struct MetricInfo {
float m_floatValue;
int m_intValue;
MetricInfo()
: m_stringValue( )
, m_floatValue( 0.0f )
, m_intValue( -1 ) {
// empty
}
MetricInfo(): m_stringValue( ), m_floatValue( 0.0f ), m_intValue( -1 ) {}
};
/** @brief This class is used to implement the OpenGEX importer
@ -97,7 +92,7 @@ public:
OpenGEXImporter();
/// The class destructor.
~OpenGEXImporter() override;
~OpenGEXImporter() override = default;
/// BaseImporter override.
bool CanRead( const std::string &file, IOSystem *pIOHandler, bool checkSig ) const override;
@ -170,7 +165,7 @@ private:
std::vector<std::string> m_Names;
RefInfo( aiNode *node, Type type, std::vector<std::string> &names );
~RefInfo();
~RefInfo() = default;
RefInfo( const RefInfo & ) = delete;
RefInfo &operator = ( const RefInfo & ) = delete;

View File

@ -40,6 +40,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "AbstractImportExportBase.h"
#include <assimp/scene.h>
#include "UnitTestPCH.h"
#include <assimp/Importer.hpp>
@ -51,11 +53,12 @@ public:
bool importerTest() override {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/OpenGEX/Example.ogex", 0);
EXPECT_EQ(1u, scene->mNumMeshes);
return nullptr != scene;
}
};
TEST_F(utOpenGEXImportExport, importLWSFromFileTest) {
TEST_F(utOpenGEXImportExport, importOpenGexFromFileTest) {
EXPECT_TRUE(importerTest());
}