Check dependencies before class attributes to avoid out-of-range exception

release/4.3a0
Richard Roberts 2012-07-13 21:54:57 +00:00
parent aa5beafd94
commit 4ae96c6642
1 changed files with 16 additions and 12 deletions

View File

@ -423,24 +423,28 @@ void Module::matlab_code(const string& toolboxPath, const string& headerPath) co
// Dependency check list
vector<string> 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<ArgumentList>(validTypes, cls.constructor.args_list);
verifyArguments<StaticMethod>(validTypes, cls.static_methods);
verifyArguments<Method>(validTypes, cls.methods);
// verify function return types
verifyReturnTypes<StaticMethod>(validTypes, cls.static_methods);
verifyReturnTypes<Method>(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<ArgumentList>(validTypes, cls.constructor.args_list);
verifyArguments<StaticMethod>(validTypes, cls.static_methods);
verifyArguments<Method>(validTypes, cls.methods);
// verify function return types
verifyReturnTypes<StaticMethod>(validTypes, cls.static_methods);
verifyReturnTypes<Method>(validTypes, cls.methods);
}
// Generate includes while avoiding redundant includes
generateIncludes(wrapperFile);