Browse Source

Remove obsolete string/number Android workarounds.

pull/205/head
Vladimír Vondruš 8 years ago
parent
commit
e3b0fab79c
  1. 26
      src/Magnum/AbstractShaderProgram.cpp
  2. 18
      src/Magnum/DebugOutput.cpp
  3. 40
      src/Magnum/Shader.cpp
  4. 67
      src/MagnumPlugins/ObjImporter/ObjImporter.cpp

26
src/Magnum/AbstractShaderProgram.cpp

@ -38,10 +38,6 @@
#include "Implementation/ShaderProgramState.h" #include "Implementation/ShaderProgramState.h"
#include "Implementation/State.h" #include "Implementation/State.h"
#ifdef CORRADE_TARGET_ANDROID
#include <sstream>
#endif
namespace Magnum { namespace Magnum {
namespace Implementation { namespace Implementation {
@ -419,36 +415,18 @@ bool AbstractShaderProgram::link(std::initializer_list<std::reference_wrapper<Ab
glGetProgramInfoLog(shader._id, message.size(), nullptr, &message[0]); glGetProgramInfoLog(shader._id, message.size(), nullptr, &message[0]);
message.resize(std::max(logLength, 1)-1); message.resize(std::max(logLength, 1)-1);
/** @todo Remove when this is fixed everywhere (also the include above) */
#ifdef CORRADE_TARGET_ANDROID
std::ostringstream converter;
converter << i;
#endif
/* Show error log */ /* Show error log */
if(!success) { if(!success) {
Error out{Debug::Flag::NoNewlineAtTheEnd}; Error out{Debug::Flag::NoNewlineAtTheEnd};
out << "AbstractShaderProgram::link(): linking"; out << "AbstractShaderProgram::link(): linking";
if(shaders.size() != 1) { if(shaders.size() != 1) out << "of shader" << i;
#ifndef CORRADE_TARGET_ANDROID
out << "of shader" << std::to_string(i);
#else
out << "of shader" << converter.str();
#endif
}
out << "failed with the following message:" << Debug::newline << message; out << "failed with the following message:" << Debug::newline << message;
/* Or just warnings, if any */ /* Or just warnings, if any */
} else if(!message.empty() && !Implementation::isProgramLinkLogEmpty(message)) { } else if(!message.empty() && !Implementation::isProgramLinkLogEmpty(message)) {
Warning out{Debug::Flag::NoNewlineAtTheEnd}; Warning out{Debug::Flag::NoNewlineAtTheEnd};
out << "AbstractShaderProgram::link(): linking"; out << "AbstractShaderProgram::link(): linking";
if(shaders.size() != 1) { if(shaders.size() != 1) out << "of shader" << i;
#ifndef CORRADE_TARGET_ANDROID
out << "of shader" << std::to_string(i);
#else
out << "of shader" << converter.str();
#endif
}
out << "succeeded with the following message:" << Debug::newline << message; out << "succeeded with the following message:" << Debug::newline << message;
} }

18
src/Magnum/DebugOutput.cpp

@ -34,10 +34,6 @@
#include "Magnum/Implementation/State.h" #include "Magnum/Implementation/State.h"
#include "Magnum/Implementation/DebugState.h" #include "Magnum/Implementation/DebugState.h"
#ifdef CORRADE_TARGET_ANDROID
#include <sstream>
#endif
namespace Magnum { namespace Magnum {
namespace { namespace {
@ -103,19 +99,7 @@ void defaultCallback(const DebugOutput::Source source, const DebugOutput::Type t
case DebugOutput::Type::Other: ; case DebugOutput::Type::Other: ;
} }
/** @todo Remove when this is fixed everywhere (also the include above) */ output << "(" << Debug::nospace << id << Debug::nospace << "):" << string;
#ifdef CORRADE_TARGET_ANDROID
std::ostringstream converter;
converter << id;
#endif
output << '(' +
#ifndef CORRADE_TARGET_ANDROID
std::to_string(id) +
#else
converter.str() +
#endif
"):" << string;
} }
} }

40
src/Magnum/Shader.cpp

@ -39,10 +39,6 @@
#include "Implementation/State.h" #include "Implementation/State.h"
#include "Implementation/ShaderState.h" #include "Implementation/ShaderState.h"
#ifdef CORRADE_TARGET_ANDROID
#include <sstream>
#endif
/* libgles-omap3-dev_4.03.00.02-r15.6 on BeagleBoard/Ångström linux 2011.3 doesn't have GLchar */ /* libgles-omap3-dev_4.03.00.02-r15.6 on BeagleBoard/Ångström linux 2011.3 doesn't have GLchar */
#ifdef MAGNUM_TARGET_GLES #ifdef MAGNUM_TARGET_GLES
typedef char GLchar; typedef char GLchar;
@ -708,12 +704,6 @@ std::vector<std::string> Shader::sources() const { return _sources; }
Shader& Shader::addSource(std::string source) { Shader& Shader::addSource(std::string source) {
if(!source.empty()) { if(!source.empty()) {
/** @todo Remove when newlib has this fixed (also the include above) */
#ifdef CORRADE_TARGET_ANDROID
std::ostringstream converter;
converter << (_sources.size()+1)/2;
#endif
/* Fix line numbers, so line 41 of third added file is marked as 3(41) /* Fix line numbers, so line 41 of third added file is marked as 3(41)
in case shader version was not Version::None, because then source 0 in case shader version was not Version::None, because then source 0
is the #version directive added in constructor. is the #version directive added in constructor.
@ -725,13 +715,7 @@ Shader& Shader::addSource(std::string source) {
order to avoid complex logic in compile() where we assert for at order to avoid complex logic in compile() where we assert for at
least some user-provided source, an empty string is added here least some user-provided source, an empty string is added here
instead. */ instead. */
if(!_sources.empty()) _sources.push_back("#line 1 " + if(!_sources.empty()) _sources.push_back("#line 1 " + std::to_string((_sources.size()+1)/2) + '\n');
#ifndef CORRADE_TARGET_ANDROID
std::to_string((_sources.size()+1)/2) +
#else
converter.str() +
#endif
'\n');
else _sources.emplace_back(); else _sources.emplace_back();
_sources.push_back(std::move(source)); _sources.push_back(std::move(source));
@ -789,36 +773,18 @@ bool Shader::compile(std::initializer_list<std::reference_wrapper<Shader>> shade
glGetShaderInfoLog(shader._id, message.size(), nullptr, &message[0]); glGetShaderInfoLog(shader._id, message.size(), nullptr, &message[0]);
message.resize(std::max(logLength, 1)-1); message.resize(std::max(logLength, 1)-1);
/** @todo Remove when this is fixed everywhere (also the include above) */
#ifdef CORRADE_TARGET_ANDROID
std::ostringstream converter;
converter << i;
#endif
/* Show error log */ /* Show error log */
if(!success) { if(!success) {
Error out{Debug::Flag::NoNewlineAtTheEnd}; Error out{Debug::Flag::NoNewlineAtTheEnd};
out << "Shader::compile(): compilation of" << shaderName(shader._type) << "shader"; out << "Shader::compile(): compilation of" << shaderName(shader._type) << "shader";
if(shaders.size() != 1) { if(shaders.size() != 1) out << i;
#ifndef CORRADE_TARGET_ANDROID
out << std::to_string(i);
#else
out << converter.str();
#endif
}
out << "failed with the following message:" << Debug::newline << message; out << "failed with the following message:" << Debug::newline << message;
/* Or just warnings, if any */ /* Or just warnings, if any */
} else if(!message.empty() && !Implementation::isShaderCompilationLogEmpty(message)) { } else if(!message.empty() && !Implementation::isShaderCompilationLogEmpty(message)) {
Warning out{Debug::Flag::NoNewlineAtTheEnd}; Warning out{Debug::Flag::NoNewlineAtTheEnd};
out << "Shader::compile(): compilation of" << shaderName(shader._type) << "shader"; out << "Shader::compile(): compilation of" << shaderName(shader._type) << "shader";
if(shaders.size() != 1) { if(shaders.size() != 1) out << i;
#ifndef CORRADE_TARGET_ANDROID
out << std::to_string(i);
#else
out << converter.str();
#endif
}
out << "succeeded with the following message:" << Debug::newline << message; out << "succeeded with the following message:" << Debug::newline << message;
} }

67
src/MagnumPlugins/ObjImporter/ObjImporter.cpp

@ -62,34 +62,15 @@ template<std::size_t size> Math::Vector<size, Float> extractFloatData(const std:
Math::Vector<size, Float> output; Math::Vector<size, Float> output;
for(std::size_t i = 0; i != size; ++i) { for(std::size_t i = 0; i != size; ++i)
#ifndef CORRADE_TARGET_ANDROID
output[i] = std::stof(data[i]); output[i] = std::stof(data[i]);
#else
/* CRAPPY ANDROID GODDAMIT! It's also not exposed in std:: namespace,
unlike std::strtoul() and others. WTF! */
char* end{};
output[i] = strtof(data[i].data(), &end);
if(end == data[i].data() || output[i] == HUGE_VALF)
throw std::exception{};
#endif
}
if(data.size() == size+1) { if(data.size() == size+1) {
/* This should be obvious from the first if, but add this just to make /* This should be obvious from the first if, but add this just to make
Clang Analyzer happy */ Clang Analyzer happy */
CORRADE_INTERNAL_ASSERT(extra); CORRADE_INTERNAL_ASSERT(extra);
#ifndef CORRADE_TARGET_ANDROID
*extra = std::stof(data.back()); *extra = std::stof(data.back());
#else
/* CRAPPY ANDROID GODDAMIT! It's also not exposed in std:: namespace,
unlike std::strtoul() and others. WTF! */
char* end{};
*extra = strtof(data.back().data(), &end);
if(end == data.back().data() || *extra == HUGE_VALF)
throw std::exception{};
#endif
} }
return output; return output;
@ -370,52 +351,16 @@ Containers::Optional<MeshData3D> ObjImporter::doMesh3D(UnsignedInt id) {
return Containers::NullOpt; return Containers::NullOpt;
} }
#ifdef CORRADE_TARGET_ANDROID
char* end{};
#endif
/* Position indices */ /* Position indices */
positionIndices.push_back( positionIndices.push_back(std::stoul(indices[0]) - positionIndexOffset);
#ifndef CORRADE_TARGET_ANDROID
std::stoul(indices[0])
#else
std::strtoul(indices[0].data(), &end, 10)
#endif
- positionIndexOffset);
#ifdef CORRADE_TARGET_ANDROID
if(end == indices[0].data()) throw std::exception{};
#endif
/* Texture coordinates */ /* Texture coordinates */
if(indices.size() == 2 || (indices.size() == 3 && !indices[1].empty())) { if(indices.size() == 2 || (indices.size() == 3 && !indices[1].empty()))
textureCoordinateIndices.push_back( textureCoordinateIndices.push_back(std::stoul(indices[1]) - textureCoordinateIndexOffset);
#ifndef CORRADE_TARGET_ANDROID
std::stoul(indices[1])
#else
std::strtoul(indices[1].data(), &end, 10)
#endif
- textureCoordinateIndexOffset);
#ifdef CORRADE_TARGET_ANDROID
if(end == indices[1].data()) throw std::exception{};
#endif
}
/* Normal indices */ /* Normal indices */
if(indices.size() == 3) { if(indices.size() == 3)
normalIndices.push_back( normalIndices.push_back(std::stoul(indices[2]) - normalIndexOffset);
#ifndef CORRADE_TARGET_ANDROID
std::stoul(indices[2])
#else
std::strtoul(indices[2].data(), &end, 10)
#endif
- normalIndexOffset);
#ifdef CORRADE_TARGET_ANDROID
if(end == indices[2].data()) throw std::exception{};
#endif
}
} }
/* Ignore unsupported keywords, error out on unknown keywords */ /* Ignore unsupported keywords, error out on unknown keywords */

Loading…
Cancel
Save