ソースを参照

Fixed lots of "" string literals that should have been U"" Unicode literals, by temporarily disabling the implicit type conversion.

David Piuva 10 時間 前
コミット
2966b6cfd7

+ 2 - 2
Source/DFPSR/api/algorithmAPI.h

@@ -94,7 +94,7 @@ String& print_collection_1D_multiline(String& target, const T& collection, const
 	string_append(target, indentation, U"{\n");
 	intptr_t maxIndex = collection.length() - 1;
 	for (intptr_t i = 0; i <= maxIndex; i++) {
-		string_toStreamIndented(target, collection[i], indentation + "\t");
+		string_toStreamIndented(target, collection[i], indentation + U"\t");
 		if (i < maxIndex) {
 			string_append(target, U",");
 		}
@@ -134,7 +134,7 @@ String& string_toStreamIndented(String& target, const Field<T>& collection, cons
 	for (intptr_t y = 0; y <= maxY; y++) {
 		string_append(target, indentation, U"\t{\n");
 		for (intptr_t x = 0; x <= maxX; x++) {
-			string_toStreamIndented(target, collection.unsafe_readAccess(IVector2D(x, y)), indentation + "\t\t");
+			string_toStreamIndented(target, collection.unsafe_readAccess(IVector2D(x, y)), indentation + U"\t\t");
 			if (x < maxX) {
 				string_append(target, U",");
 			}

+ 15 - 15
Source/DFPSR/api/fontAPI.cpp

@@ -36,77 +36,77 @@ RasterFont font_getDefault() {
 
 RasterFont font_createLatinOne(const String& name, const ImageU8& atlas) {
 	if (!image_exists(atlas)) {
-		throwError("Cannot create the Latin-1 font called ", name, " from an empty image handle.\n");
+		throwError(U"Cannot create the Latin-1 font called ", name, U" from an empty image handle.\n");
 	} else if (image_getWidth(atlas) % 16 == 0 && image_getHeight(atlas) % 16 == 0
 		&& image_getWidth(atlas) >= 16 && image_getHeight(atlas) >= 16) {
-		throwError("Cannot create the Latin-1 font called ", name, " from an image of ", image_getWidth(atlas), "x", image_getHeight(atlas), " pixels.\n");
+		throwError(U"Cannot create the Latin-1 font called ", name, U" from an image of ", image_getWidth(atlas), U"x", image_getHeight(atlas), U" pixels.\n");
 	}
 	return RasterFontImpl::createLatinOne(name, atlas);
 }
 
 String font_getName(const RasterFont font) {
 	if (!font_exists(font)) {
-		throwError("font_getName: font must exist!");
+		throwError(U"font_getName: font must exist!");
 	}
 	return font->name;
 }
 
 int32_t font_getSize(const RasterFont font) {
 	if (!font_exists(font)) {
-		throwError("font_getSize: font must exist!");
+		throwError(U"font_getSize: font must exist!");
 	}
 	return font->size;
 }
 
 int32_t font_getSpacing(const RasterFont font) {
 	if (!font_exists(font)) {
-		throwError("font_getSpacing: font must exist!");
+		throwError(U"font_getSpacing: font must exist!");
 	}
 	return font->spacing;
 }
 
 int32_t font_getTabWidth(const RasterFont font) {
 	if (!font_exists(font)) {
-		throwError("font_getTabWidth: font must exist!");
+		throwError(U"font_getTabWidth: font must exist!");
 	}
 	return font->tabWidth;
 }
 
 int32_t font_getCharacterWidth(const RasterFont font, DsrChar unicodeValue) {
 	if (!font_exists(font)) {
-		throwError("font_getCharacterWidth: font must exist!");
+		throwError(U"font_getCharacterWidth: font must exist!");
 	}
 	return font->getCharacterWidth(unicodeValue);
 }
 
 int32_t font_getMonospaceWidth(const RasterFont font) {
 	if (!font_exists(font)) {
-		throwError("font_getMonospaceWidth: font must exist!");
+		throwError(U"font_getMonospaceWidth: font must exist!");
 	}
 	return font->widest + font->spacing;
 }
 
 int32_t font_getLineWidth(const RasterFont font, const ReadableString& content) {
 	if (!font_exists(font)) {
-		throwError("font_getLineWidth: font must exist!");
+		throwError(U"font_getLineWidth: font must exist!");
 	}
 	return font->getLineWidth(content);
 }
 
 int32_t font_printCharacter(ImageRgbaU8& target, const RasterFont font, DsrChar unicodeValue, const IVector2D& location, const ColorRgbaI32& color) {
 	if (!image_exists(target)) {
-		throwError("font_printCharacter: target must exist!");
+		throwError(U"font_printCharacter: target must exist!");
 	} else if (!font_exists(font)) {
-		throwError("font_printCharacter: font must exist!");
+		throwError(U"font_printCharacter: font must exist!");
 	}
 	return font->printCharacter(target, unicodeValue, location, color);
 }
 
 void font_printLine(ImageRgbaU8& target, const RasterFont font, const ReadableString& content, const IVector2D& location, const ColorRgbaI32& color) {
 	if (!image_exists(target)) {
-		throwError("font_printLine: target must exist!");
+		throwError(U"font_printLine: target must exist!");
 	} else if (!font_exists(font)) {
-		throwError("font_printLine: font must exist!");
+		throwError(U"font_printLine: font must exist!");
 	} else {
 		font->printLine(target, content, location, color);
 	}
@@ -114,9 +114,9 @@ void font_printLine(ImageRgbaU8& target, const RasterFont font, const ReadableSt
 
 void font_printMultiLine(ImageRgbaU8& target, const RasterFont font, const ReadableString& content, const IRect& bound, const ColorRgbaI32& color) {
 	if (!image_exists(target)) {
-		throwError("font_printMultiLine: target must exist!");
+		throwError(U"font_printMultiLine: target must exist!");
 	} else if (!font_exists(font)) {
-		throwError("font_printMultiLine: font must exist!");
+		throwError(U"font_printMultiLine: font must exist!");
 	} else {
 		font->printMultiLine(target, content, bound, color);
 	}

+ 3 - 3
Source/DFPSR/implementation/gui/DsrWindow.cpp

@@ -128,11 +128,11 @@ Handle<VisualComponent> DsrWindow::getRootComponent() const {
 
 void DsrWindow::resetInterface() {
 	// Create an empty main panel
-	this->mainPanel = handle_dynamicCast<VisualComponent>(createPersistentClass("Panel"));
+	this->mainPanel = handle_dynamicCast<VisualComponent>(createPersistentClass(U"Panel"));
 	if (this->mainPanel.isNull()) {
 		throwError(U"DsrWindow::resetInterface: The window's Panel could not be created!");
 	}
-	this->mainPanel->setName("mainPanel");
+	this->mainPanel->setName(U"mainPanel");
 	// Inherit handle to backend window to access the clipboard.
 	this->mainPanel->window = this->backend;
 	this->applyLayout();
@@ -144,7 +144,7 @@ void DsrWindow::loadInterfaceFromString(String layout, const ReadableString &fro
 	// Re-assign the backend window handle
 	setBackendWindowHandle(this->mainPanel, this->backend);
 	if (this->mainPanel.isNull()) {
-		throwError(U"DsrWindow::loadInterfaceFromString: The window's root component could not be created!\n\nLayout:\n", layout, "\n");
+		throwError(U"DsrWindow::loadInterfaceFromString: The window's root component could not be created!\n\nLayout:\n", layout, U"\n");
 	}
 	this->applyLayout();
 }

+ 1 - 1
Source/DFPSR/implementation/persistent/atomic/PersistentString.h

@@ -33,7 +33,7 @@ public:
 	PERSISTENT_DECLARATION(PersistentString)
 	String value;
 public:
-	PersistentString() : value("") {}
+	PersistentString() : value(U"") {}
 	// Because the constructor from text is used for serialization, an explicit constructor must be used to avoid mangling
 	static PersistentString unmangled(const ReadableString &text);
 public:

+ 8 - 8
Source/DFPSR/implementation/render/ResourcePool.cpp

@@ -52,31 +52,31 @@ int32_t BasicResourcePool::findTextureRgba(const ReadableString& name) const {
 
 const ImageRgbaU8 BasicResourcePool::fetchImageRgba(const ReadableString& name) {
 	ImageRgbaU8 result;
-	// Using "" will return an empty reference to allow removing textures
+	// Using U"" will return an empty reference to allow removing textures
 	if (string_length(name) > 0) {
 		int32_t existingIndex = this->findImageRgba(name);
 		if (existingIndex > -1) {
 			result = this->imageRgbaList[existingIndex].resource;
 		} else if (string_findFirst(name, U'.') > -1) {
-			throwError("The image \"", name, "\" had a forbidden dot in the name. Images in resource pools are fetched without the extension to allow changing image format without changing what it's called in other resources.\n");
+			throwError(U"The image \"", name, U"\" had a forbidden dot in the name. Images in resource pools are fetched without the extension to allow changing image format without changing what it's called in other resources.\n");
 		} else if (string_findFirst(name, U'/') > -1 && string_findFirst(name, U'\\') > -1) {
-			throwError("The image \"", name, "\" contained a path separator, which is not allowed because of ambiguity. The same file can have multiple paths to the same folder and multiple files can have the same name in different folders.\n");
+			throwError(U"The image \"", name, U"\" contained a path separator, which is not allowed because of ambiguity. The same file can have multiple paths to the same folder and multiple files can have the same name in different folders.\n");
 		} else {
 			// Look for a png image
 			const String extensionless = file_combinePaths(this->path, name);
-			result = image_load_RgbaU8(extensionless + ".png", false);
+			result = image_load_RgbaU8(extensionless + U".png", false);
 			// Look for gif
 			if (!image_exists(result)) {
-				result = image_load_RgbaU8(extensionless + ".gif", false);
+				result = image_load_RgbaU8(extensionless + U".gif", false);
 			}
 			// Look for jpg
 			if (!image_exists(result)) {
-				result = image_load_RgbaU8(extensionless + ".jpg", false);
+				result = image_load_RgbaU8(extensionless + U".jpg", false);
 			}
 			if (image_exists(result)) {
 				this->imageRgbaList.push(namedEntry<ImageRgbaU8>(name, result));
 			} else {
-				printText("The image ", extensionless, ".* couldn't be loaded as either png, gif nor jpg!\n");
+				printText(U"The image ", extensionless, U".* couldn't be loaded as either png, gif nor jpg!\n");
 			}
 		}
 	}
@@ -85,7 +85,7 @@ const ImageRgbaU8 BasicResourcePool::fetchImageRgba(const ReadableString& name)
 
 const TextureRgbaU8 BasicResourcePool::fetchTextureRgba(const ReadableString& name, int32_t resolutions) {
 	TextureRgbaU8 result;
-	// Using "" will return an empty reference to allow removing textures
+	// Using U"" will return an empty reference to allow removing textures
 	if (string_length(name) > 0) {
 		int32_t existingTextureIndex = this->findTextureRgba(name);
 		int32_t existingImageIndex = this->findImageRgba(name);

+ 5 - 5
Source/DFPSR/implementation/render/model/Model.cpp

@@ -31,15 +31,15 @@
 
 using namespace dsr;
 
-#define CHECK_PART_INDEX(PART_INDEX, EXIT_STMT) if (PART_INDEX < 0 || PART_INDEX >= this->partBuffer.length()) { printText("Part index ", PART_INDEX, " is out of range 0..", this->partBuffer.length() - 1, "!\n"); EXIT_STMT; }
-#define CHECK_POLYGON_INDEX(PART_PTR, POLYGON_INDEX, EXIT_STMT) if (POLYGON_INDEX < 0 || POLYGON_INDEX >= PART_PTR->polygonBuffer.length()) { printText("Polygon index ", POLYGON_INDEX, " is out of range 0..", PART_PTR->polygonBuffer.length() - 1, "!\n"); EXIT_STMT; }
-#define CHECK_POINT_INDEX(POINT_INDEX, EXIT_STMT) if (POINT_INDEX < 0 || POINT_INDEX >= this->positionBuffer.length()) { printText("Position index ", POINT_INDEX, " is out of range 0..", this->positionBuffer.length() - 1, "!\n"); EXIT_STMT; }
+#define CHECK_PART_INDEX(PART_INDEX, EXIT_STMT) if (PART_INDEX < 0 || PART_INDEX >= this->partBuffer.length()) { printText(U"Part index ", PART_INDEX, U" is out of range 0..", this->partBuffer.length() - 1, U"!\n"); EXIT_STMT; }
+#define CHECK_POLYGON_INDEX(PART_PTR, POLYGON_INDEX, EXIT_STMT) if (POLYGON_INDEX < 0 || POLYGON_INDEX >= PART_PTR->polygonBuffer.length()) { printText(U"Polygon index ", POLYGON_INDEX, U" is out of range 0..", PART_PTR->polygonBuffer.length() - 1, U"!\n"); EXIT_STMT; }
+#define CHECK_POINT_INDEX(POINT_INDEX, EXIT_STMT) if (POINT_INDEX < 0 || POINT_INDEX >= this->positionBuffer.length()) { printText(U"Position index ", POINT_INDEX, U" is out of range 0..", this->positionBuffer.length() - 1, U"!\n"); EXIT_STMT; }
 #define CHECK_PART_POLYGON_INDEX(PART_INDEX, POLYGON_INDEX, EXIT_STMT) { \
 	CHECK_PART_INDEX(PART_INDEX, EXIT_STMT); \
 	const Part *PartPtr = &(this->partBuffer[PART_INDEX]); \
 	CHECK_POLYGON_INDEX(PartPtr, POLYGON_INDEX, EXIT_STMT); \
 }
-#define CHECK_VERTEX_INDEX(VERTEX_INDEX, EXIT_STMT) if (VERTEX_INDEX < 0 || VERTEX_INDEX > 3) { printText("Vertex index ", VERTEX_INDEX, " is out of the fixed range 0..3 for triangles and quads!\n"); EXIT_STMT; }
+#define CHECK_VERTEX_INDEX(VERTEX_INDEX, EXIT_STMT) if (VERTEX_INDEX < 0 || VERTEX_INDEX > 3) { printText(U"Vertex index ", VERTEX_INDEX, U" is out of the fixed range 0..3 for triangles and quads!\n"); EXIT_STMT; }
 
 Polygon::Polygon(const Vertex &vertA, const Vertex &vertB, const Vertex &vertC) {
 	this->pointIndices[0] = vertA.pointIndex;
@@ -230,7 +230,7 @@ void ModelImpl::setPartName(int32_t partIndex, const String &name) {
 	this->partBuffer[partIndex].name = name;
 }
 String ModelImpl::getPartName(int32_t partIndex) const {
-	CHECK_PART_INDEX(partIndex, return "");
+	CHECK_PART_INDEX(partIndex, return U"");
 	return this->partBuffer[partIndex].name;
 }
 TextureRgbaU8 ModelImpl::getDiffuseMap(int32_t partIndex) const {

+ 1 - 1
Source/SDK/camera/main.cpp

@@ -168,7 +168,7 @@ void dsrMain(List<String> args) {
 
 	// Create a room model
 	Model roomModel = createRoomModel(roomMinimum, roomMaximum);
-	model_setDiffuseMapByName(roomModel, 0, pool, "Grid");
+	model_setDiffuseMapByName(roomModel, 0, pool, U"Grid");
 
 	// Create a renderer for multi-threading
 	Renderer worker = renderer_create();

+ 1 - 1
Source/SDK/cube/main.cpp

@@ -100,7 +100,7 @@ void dsrMain(List<String> args) {
 
 	// Create a cube model
 	Model cubeModel = createCubeModel(FVector3D(-0.5f), FVector3D(0.5f));
-	model_setDiffuseMapByName(cubeModel, 0, pool, "RGB");
+	model_setDiffuseMapByName(cubeModel, 0, pool, U"RGB");
 	model_setFilter(cubeModel, Filter::Alpha);
 
 	// Import models

+ 8 - 8
Source/SDK/fileFinder/main.cpp

@@ -9,33 +9,33 @@ using namespace dsr;
 
 void exploreFolder(const ReadableString& folderPath, const ReadableString& indentation) {
 	if (!file_getFolderContent(folderPath, [indentation](const ReadableString& entryPath, const ReadableString& entryName, EntryType entryType) {
-		printText(indentation, "* Entry: ", entryName, " as ", entryType, "\n");
+		printText(indentation, U"* Entry: ", entryName, U" as ", entryType, U"\n");
 		if (entryType == EntryType::Folder) {
-			exploreFolder(entryPath, indentation + "  ");
+			exploreFolder(entryPath, indentation + U"  ");
 		}
 	})) {
-		printText("Failed to explore ", folderPath, "\n");
+		printText(U"Failed to explore ", folderPath, U"\n");
 	}
 }
 
 DSR_MAIN_CALLER(dsrMain)
 void dsrMain(List<String> args) {
-	printText("Input arguments:\n");
+	printText(U"Input arguments:\n");
 	for (int32_t a = 0; a < args.length(); a++) {
-		printText("  args[", a, "] = ", args[a], "\n");
+		printText(U"  args[", a, U"] = ", args[a], U"\n");
 	}
 	String absolutePath = file_getAbsolutePath(args[0]);
-	printText("Absolute path = ", absolutePath, "\n");
+	printText(U"Absolute path = ", absolutePath, U"\n");
 	if (args.length() > 1) {
 		// Explore each listed folder from input arguments.
 		for (int32_t a = 1; a < args.length(); a++) {
-			printText("Exploring ", args[a], "\n");
+			printText(U"Exploring ", args[a], U"\n");
 			exploreFolder(args[a], U"  ");
 		}
 	} else {
 		// Test program on the current path when nothing was entered.
 		String applicationFolder = file_getApplicationFolder();
-		printText("Exploring ", applicationFolder, " because no folders were given.\n");
+		printText(U"Exploring ", applicationFolder, U" because no folders were given.\n");
 		exploreFolder(applicationFolder, U"  ");
 	}
 }