smarter type extraction in python_to_value

This commit is contained in:
Dane Springmeyer 2014-10-27 09:22:54 -07:00
parent b860b58f0f
commit 180bc17fc6

View file

@ -82,29 +82,37 @@ namespace mapnik {
continue; continue;
} }
extract<std::string> ex0(obj); if (PyBool_Check(obj.ptr()))
if (ex0.check())
{ {
vars[key] = tr_.transcode(ex0().c_str()); extract<mapnik::value_bool> ex(obj);
continue; if (ex.check())
{
vars[key] = ex();
}
} }
extract<mapnik::value_integer> ex2(obj); else if (PyFloat_Check(obj.ptr()))
if (ex2.check())
{ {
vars[key] = ex2(); extract<mapnik::value_double> ex(obj);
continue; if (ex.check())
{
vars[key] = ex();
}
} }
extract<double> ex3(obj); else
if (ex3.check())
{ {
vars[key] = ex3(); extract<mapnik::value_integer> ex(obj);
continue; if (ex.check())
} {
extract<mapnik::value_bool> ex1(obj); vars[key] = ex();
if (ex1.check()) }
{ else
vars[key] = ex1(); {
continue; extract<std::string> ex0(obj);
if (ex0.check())
{
vars[key] = tr_.transcode(ex0().c_str());
}
}
} }
} }
return vars; return vars;