[Scummvm-cvs-logs] SF.net SVN: scummvm:[45442] scummvm/trunk/tools/create_msvc

lordhoto at users.sourceforge.net lordhoto at users.sourceforge.net
Tue Oct 27 19:36:06 CET 2009


Revision: 45442
          http://scummvm.svn.sourceforge.net/scummvm/?rev=45442&view=rev
Author:   lordhoto
Date:     2009-10-27 18:36:06 +0000 (Tue, 27 Oct 2009)

Log Message:
-----------
Got rid of use of exceptions.

Modified Paths:
--------------
    scummvm/trunk/tools/create_msvc/create_msvc.cpp
    scummvm/trunk/tools/create_msvc/create_msvc.h

Modified: scummvm/trunk/tools/create_msvc/create_msvc.cpp
===================================================================
--- scummvm/trunk/tools/create_msvc/create_msvc.cpp	2009-10-27 18:35:20 UTC (rev 45441)
+++ scummvm/trunk/tools/create_msvc/create_msvc.cpp	2009-10-27 18:36:06 UTC (rev 45442)
@@ -227,13 +227,7 @@
 	setup.libraries.push_back("winmm.lib");
 	setup.libraries.push_back("sdl.lib");
 
-	try {
-		createMSVCProject(setup, msvcVersion);
-	} catch (const std::string &error) {
-		std::cerr << "ERROR: " << error << "!" << std::endl;
-	} catch (const std::exception &exp) {
-		std::cerr << "ERROR: " << exp.what() << "!" << std::endl;
-	}
+	createMSVCProject(setup, msvcVersion);
 }
 
 namespace {
@@ -363,7 +357,7 @@
 			break;
 
 		if (configure.fail())
-			throw std::string("Failed while reading from " + configureFile);
+			error("Failed while reading from " + configureFile);
 
 		EngineDesc desc;
 		if (parseEngine(line, desc))
@@ -709,11 +703,11 @@
 std::string createUUID() {
 	UUID uuid;
 	if (UuidCreate(&uuid) != RPC_S_OK)
-		throw std::string("UuidCreate failed");
+		error("UuidCreate failed");
 
 	unsigned char *string = 0;
 	if (UuidToStringA(&uuid, &string) != RPC_S_OK)
-		throw std::string("UuidToStringA failed");
+		error("UuidToStringA failed");
 
 	std::string result = std::string((char *)string);
 	std::transform(result.begin(), result.end(), result.begin(), toupper);
@@ -724,7 +718,7 @@
 void createScummVMSolution(const BuildSetup &setup, const UUIDMap &uuids, const int version) {
 	UUIDMap::const_iterator svmUUID = uuids.find("scummvm");
 	if (svmUUID == uuids.end())
-		throw std::string("No UUID for \"scummvm\" project created");
+		error("No UUID for \"scummvm\" project created");
 
 	const std::string svmProjectUUID = svmUUID->second;
 	assert(!svmProjectUUID.empty());
@@ -733,7 +727,7 @@
 
 	std::ofstream solution((setup.outputDir + '/' + "scummvm.sln").c_str());
 	if (!solution)
-		throw std::string("Could not open \"" + setup.outputDir + '/' + "scummvm.sln\" for writing");
+		error("Could not open \"" + setup.outputDir + '/' + "scummvm.sln\" for writing");
 
 	solution << "Microsoft Visual Studio Solution File, Format Version " << version + 1 << ".00\n";
 	if (version == 9)
@@ -741,7 +735,7 @@
 	else if (version == 8)
 		solution << "# Visual Studio 2005\n";
 	else
-		throw std::string("Unsupported version passed to createScummVMSolution");
+		error("Unsupported version passed to createScummVMSolution");
 
 	solution << "Project(\"{" << solutionUUID << "}\") = \"scummvm\", \"scummvm.vcproj\", \"{" << svmProjectUUID << "}\"\n"
 	         << "\tProjectSection(ProjectDependencies) = postProject\n";
@@ -796,7 +790,7 @@
 	const std::string projectFile = setup.outputDir + '/' + name + ".vcproj";
 	std::ofstream project(projectFile.c_str());
 	if (!project)
-		throw std::string("Could not open \"" + projectFile + "\" for writing");
+		error("Could not open \"" + projectFile + "\" for writing");
 
 	project << "<?xml version=\"1.0\" encoding=\"windows-1252\"?>\n"
 	           "<VisualStudioProject\n"
@@ -940,7 +934,7 @@
 void createGlobalProp(const BuildSetup &setup, const int /*version*/) {
 	std::ofstream properties((setup.outputDir + '/' + "ScummVM_Global.vsprops").c_str());
 	if (!properties)
-		throw std::string("Could not open \"" + setup.outputDir + '/' + "ScummVM_Global.vsprops\" for writing");
+		error("Could not open \"" + setup.outputDir + '/' + "ScummVM_Global.vsprops\" for writing");
 
 	std::string defines;
 	for (StringList::const_iterator i = setup.defines.begin(); i != setup.defines.end(); ++i) {
@@ -954,7 +948,7 @@
 
 	properties.open((setup.outputDir + '/' + "ScummVM_Global64.vsprops").c_str());
 	if (!properties)
-		throw std::string("Could not open \"" + setup.outputDir + '/' + "ScummVM_Global64.vsprops\" for writing");
+		error("Could not open \"" + setup.outputDir + '/' + "ScummVM_Global64.vsprops\" for writing");
 
 	// HACK: We must disable the "nasm" feature for x64. To achieve that we must duplicate the feature list and
 	// recreate a define list.
@@ -977,7 +971,7 @@
 void createBuildProp(const BuildSetup &setup, const int /*version*/) {
 	std::ofstream properties((setup.outputDir + '/' + "ScummVM_Debug.vsprops").c_str());
 	if (!properties)
-		throw std::string("Could not open \"" + setup.outputDir + '/' + "ScummVM_Debug.vsprops\" for writing");
+		error("Could not open \"" + setup.outputDir + '/' + "ScummVM_Debug.vsprops\" for writing");
 
 	properties << "<?xml version=\"1.0\" encoding=\"Windows-1252\"?>\n"
 	              "<VisualStudioPropertySheet\n"
@@ -1010,7 +1004,7 @@
 
 	properties.open((setup.outputDir + '/' + "ScummVM_Debug64.vsprops").c_str());
 	if (!properties)
-		throw std::string("Could not open \"" + setup.outputDir + '/' + "ScummVM_Debug64.vsprops\" for writing");
+		error("Could not open \"" + setup.outputDir + '/' + "ScummVM_Debug64.vsprops\" for writing");
 
 	properties << "<?xml version=\"1.0\" encoding=\"Windows-1252\"?>\n"
 	              "<VisualStudioPropertySheet\n"
@@ -1043,7 +1037,7 @@
 
 	properties.open((setup.outputDir + '/' + "ScummVM_Release.vsprops").c_str());
 	if (!properties)
-		throw std::string("Could not open \"" + setup.outputDir + '/' + "ScummVM_Release.vsprops\" for writing");
+		error("Could not open \"" + setup.outputDir + '/' + "ScummVM_Release.vsprops\" for writing");
 
 	properties << "<?xml version=\"1.0\" encoding=\"Windows-1252\"?>\n"
 	              "<VisualStudioPropertySheet\n"
@@ -1074,7 +1068,7 @@
 
 	properties.open((setup.outputDir + '/' + "ScummVM_Release64.vsprops").c_str());
 	if (!properties)
-		throw std::string("Could not open \"" + setup.outputDir + '/' + "ScummVM_Release64.vsprops\" for writing");
+		error("Could not open \"" + setup.outputDir + '/' + "ScummVM_Release64.vsprops\" for writing");
 
 	properties << "<?xml version=\"1.0\" encoding=\"Windows-1252\"?>\n"
 	              "<VisualStudioPropertySheet\n"
@@ -1265,6 +1259,7 @@
 		return 0;
 
 	FileNode *result = new FileNode(dir);
+	assert(result);
 
 	do {
 		if (fileInformation.cFileName[0] == '.')
@@ -1426,7 +1421,7 @@
 	const std::string moduleMkFile = moduleDir + "/module.mk";
 	std::ifstream moduleMk(moduleMkFile.c_str());
 	if (!moduleMk)
-		throw std::string(moduleMkFile + " is not present");
+		error(moduleMkFile + " is not present");
 
 	includeList.push_back(moduleMkFile);
 
@@ -1442,7 +1437,7 @@
 			break;
 
 		if (moduleMk.fail())
-			throw std::string("Failed while reading from " + moduleMkFile);
+			error("Failed while reading from " + moduleMkFile);
 
 		TokenList tokens = tokenize(line);
 		if (tokens.empty())
@@ -1451,23 +1446,23 @@
 		TokenList::const_iterator i = tokens.begin();
 		if (*i == "MODULE") {
 			if (hadModule)
-				throw std::string("More than one MODULE definition in " + moduleMkFile);
+				error("More than one MODULE definition in " + moduleMkFile);
 			// Format: "MODULE := path/to/module"
 			if (tokens.size() < 3)
-				throw std::string("Malformed MODULE definition in " + moduleMkFile);
+				error("Malformed MODULE definition in " + moduleMkFile);
 			++i;
 			if (*i != ":=")
-				throw std::string("Malformed MODULE definition in " + moduleMkFile);
+				error("Malformed MODULE definition in " + moduleMkFile);
 			++i;
 
 			std::string moduleRoot = unifyPath(*i);
 			if (moduleDir.compare(moduleDir.size() - moduleRoot.size(), moduleRoot.size(), moduleRoot))
-				throw std::string("MODULE root " + moduleRoot + " does not match base dir " + moduleDir);
+				error("MODULE root " + moduleRoot + " does not match base dir " + moduleDir);
 
 			hadModule = true;
 		} else if (*i == "MODULE_OBJS") {
 			if (tokens.size() < 3)
-				throw std::string("Malformed MODULE_OBJS definition in " + moduleMkFile);
+				error("Malformed MODULE_OBJS definition in " + moduleMkFile);
 			++i;
 
 			// This is not exactly correct, for example an ":=" would usually overwrite
@@ -1477,7 +1472,7 @@
 			// by this function, thus we can't just clear them on ":=" or "=").
 			// But hopefully our module.mk files will never do such things anyway.
 			if (*i != ":=" && *i != "+=" && *i != "=")
-				throw std::string("Malformed MODULE_OBJS definition in " + moduleMkFile);
+				error("Malformed MODULE_OBJS definition in " + moduleMkFile);
 
 			++i;
 
@@ -1496,7 +1491,7 @@
 			}
 		} else if (*i == "ifdef") {
 			if (tokens.size() < 2)
-				throw std::string("Malformed ifdef in " + moduleMkFile);
+				error("Malformed ifdef in " + moduleMkFile);
 			++i;
 
 			if (std::find(defines.begin(), defines.end(), *i) == defines.end())
@@ -1505,7 +1500,7 @@
 				shouldInclude.push(true);
 		} else if (*i == "ifndef") {
 			if (tokens.size() < 2)
-				throw std::string("Malformed ifndef in " + moduleMkFile);
+				error("Malformed ifndef in " + moduleMkFile);
 			++i;
 
 			if (std::find(defines.begin(), defines.end(), *i) == defines.end())
@@ -1516,10 +1511,10 @@
 			shouldInclude.top() = !shouldInclude.top();
 		} else if (*i == "endif") {
 			if (shouldInclude.size() <= 1)
-				throw std::string("endif without ifdef found in " + moduleMkFile);
+				error("endif without ifdef found in " + moduleMkFile);
 			shouldInclude.pop();
 		} else if (*i == "elif") {
-			throw std::string("Unsupported operation 'elif' in " + moduleMkFile);
+			error("Unsupported operation 'elif' in " + moduleMkFile);
 		} else if (*i == "ifeq") {
 			//XXX
 			shouldInclude.push(false);
@@ -1527,6 +1522,12 @@
 	}
 
 	if (shouldInclude.size() != 1)
-		throw std::string("Malformed file " + moduleMkFile);
+		error("Malformed file " + moduleMkFile);
 }
 } // End of anonymous namespace
+
+void error(const std::string &message) {
+	std::cerr << "ERROR: " << message << "!" << std::endl;
+	std::exit(-1);
+}
+

Modified: scummvm/trunk/tools/create_msvc/create_msvc.h
===================================================================
--- scummvm/trunk/tools/create_msvc/create_msvc.h	2009-10-27 18:35:20 UTC (rev 45441)
+++ scummvm/trunk/tools/create_msvc/create_msvc.h	2009-10-27 18:36:06 UTC (rev 45442)
@@ -205,4 +205,11 @@
  */
 void createMSVCProject(const BuildSetup &setup, const int version);
 
+/**
+ * Quits the program with the specified error message.
+ *
+ * @param message The error message to print to stderr.
+ */
+void error(const std::string &message);
+
 #endif


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list