Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Android 32-bit build #1006

Merged
merged 4 commits into from
Oct 17, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions src/autowiring/marshaller.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include <stdio.h>
#include TYPE_TRAITS_HEADER

#if __ANDROID__
#if defined(__ANDROID__) && !defined(_LIBCPP_VERSION)
#include <sstream>
#endif

Expand Down Expand Up @@ -141,13 +141,13 @@ namespace autowiring {

std::string marshal(const void* ptr) const override {
type val = *static_cast<const type*>(ptr);
#if __ANDROID__
#if defined(__ANDROID__) && !defined(_LIBCPP_VERSION)
std::stringstream ss;
ss << val;
return ss.str();
#else
return std::to_string(val);
#endif //__ANDROID__
#endif
}

void unmarshal(void* ptr, const char* szValue) const override {
Expand Down Expand Up @@ -200,7 +200,16 @@ namespace autowiring {

template<>
struct float_converter<long double> {
static long double convertTo(const char* szValue) { return strtold(szValue, nullptr); }
static long double convertTo(const char* szValue) {
#if defined(__ANDROID__) && !defined(__aarch64__) && !defined(_LIBCPP_VERSION)
std::stringstream ss(szValue);
long double ld;
ss >> ld;
return ld;
#else
return strtold(szValue, nullptr);
#endif
}
static std::string convertFrom(long double value) {
return var_to_string<long double, 128>(value, "%.33Lg");
}
Expand Down
14 changes: 0 additions & 14 deletions src/autowiring/test/MarshallerTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,6 @@ TEST_F(MarshallerTest, FloatTest) {
ASSERT_STREQ("123000000", valZ.c_str()) << "Failed to marshal a value with an exponent";
}

TEST_F(MarshallerTest, DISABLED_FloatRoundTrip_FULL) {
autowiring::marshaller<float> f;

const float start = std::numeric_limits<float>::min();
const float end = std::numeric_limits<float>::max();

for (float x = start; x != end; x = std::nextafterf(x, end)) {
std::string str = f.marshal(&x);
float roundtrip;
f.unmarshal(&roundtrip, str.c_str());
ASSERT_EQ(x, roundtrip) << "Floating point value did not round trip correctly";
}
}

TEST_F(MarshallerTest, DoubleMarshalTest) {
autowiring::marshaller<double> d;

Expand Down