From 4ae96c6642c6e17476bfc2ccd058cafc927e8f61 Mon Sep 17 00:00:00 2001 From: Richard Roberts Date: Fri, 13 Jul 2012 21:54:57 +0000 Subject: [PATCH] Check dependencies before class attributes to avoid out-of-range exception --- wrap/Module.cpp | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/wrap/Module.cpp b/wrap/Module.cpp index 707d91dc4..a6fa3da20 100644 --- a/wrap/Module.cpp +++ b/wrap/Module.cpp @@ -423,24 +423,28 @@ void Module::matlab_code(const string& toolboxPath, const string& headerPath) co // Dependency check list vector validTypes = GenerateValidTypes(expandedClasses, forward_declarations); + // Check that all classes have been defined somewhere + BOOST_FOREACH(const Class& cls, expandedClasses) { + // verify all of the function arguments + //TODO:verifyArguments(validTypes, cls.constructor.args_list); + verifyArguments(validTypes, cls.static_methods); + verifyArguments(validTypes, cls.methods); + + // verify function return types + verifyReturnTypes(validTypes, cls.static_methods); + verifyReturnTypes(validTypes, cls.methods); + + // verify parents + if(!cls.qualifiedParent.empty() && std::find(validTypes.begin(), validTypes.end(), wrap::qualifiedName("::", cls.qualifiedParent)) == validTypes.end()) + throw DependencyMissing(wrap::qualifiedName("::", cls.qualifiedParent), cls.qualifiedName("::")); + } + // Create type attributes table and check validity TypeAttributesTable typeAttributes; typeAttributes.addClasses(expandedClasses); typeAttributes.addForwardDeclarations(forward_declarations); typeAttributes.checkValidity(expandedClasses); - // Check that all classes have been defined somewhere - BOOST_FOREACH(const Class& cls, expandedClasses) { - // verify all of the function arguments - //TODO:verifyArguments(validTypes, cls.constructor.args_list); - verifyArguments(validTypes, cls.static_methods); - verifyArguments(validTypes, cls.methods); - - // verify function return types - verifyReturnTypes(validTypes, cls.static_methods); - verifyReturnTypes(validTypes, cls.methods); - } - // Generate includes while avoiding redundant includes generateIncludes(wrapperFile);