[glom/glom-1-18] Handle gdouble results from python functions.
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glom/glom-1-18] Handle gdouble results from python functions.
- Date: Fri, 4 Nov 2011 10:27:19 +0000 (UTC)
commit 26b0c340288326636f25daf9ec3fddcb1f940b03
Author: Murray Cumming <murrayc murrayc com>
Date: Fri Nov 4 11:14:11 2011 +0100
Handle gdouble results from python functions.
* glom/libglom/data_structure/field.cc: Add a mapping
instead of ignoring doubles.
This avoids a stderr warning and probably makes calculations
work.
Conflicts:
glom/python_embed/glom_python.cc
glom/libglom/data_structure/field.cc | 7 ++++++-
.../libglom/python_embed/pygdavalue_conversions.cc | 6 ++++--
glom/python_embed/glom_python.cc | 13 ++++++++++++-
3 files changed, 22 insertions(+), 4 deletions(-)
---
diff --git a/glom/libglom/data_structure/field.cc b/glom/libglom/data_structure/field.cc
index 34e6004..a03c66c 100644
--- a/glom/libglom/data_structure/field.cc
+++ b/glom/libglom/data_structure/field.cc
@@ -599,7 +599,7 @@ Field::glom_field_type Field::get_glom_type_for_gda_type(GType gda_type)
result = iterFind->second;
else
{
- // g_warning("FieldType::FieldType(GType gda_type): Invalid gda type: %d", gda_type);
+ std::cerr << G_STRFUNC << ": Unhandled GType: " << g_type_name(gda_type) << std::endl;
}
}
@@ -642,6 +642,11 @@ void Field::init_map()
m_map_gda_type_to_glom_type[G_TYPE_BOOLEAN] = TYPE_BOOLEAN;
m_map_gda_type_to_glom_type[GDA_TYPE_BINARY] = TYPE_IMAGE;
+ //Extra conversions for GTypes that can be returned by glom_pygda_value_from_pyobject():
+ m_map_gda_type_to_glom_type[G_TYPE_DOUBLE] = TYPE_NUMERIC;
+ //TODO? m_map_gda_type_to_glom_type[GDA_TYPE_TIME] = ;
+ //TODO? m_map_gda_type_to_glom_type[GDA_TYPE_TIMESTAMP] = ;
+
m_map_glom_type_to_gda_type[TYPE_NUMERIC] = GDA_TYPE_NUMERIC;
m_map_glom_type_to_gda_type[TYPE_TEXT] = G_TYPE_STRING;
m_map_glom_type_to_gda_type[TYPE_TIME] = GDA_TYPE_TIME;
diff --git a/glom/libglom/python_embed/pygdavalue_conversions.cc b/glom/libglom/python_embed/pygdavalue_conversions.cc
index 80ffc1b..d377b33 100644
--- a/glom/libglom/python_embed/pygdavalue_conversions.cc
+++ b/glom/libglom/python_embed/pygdavalue_conversions.cc
@@ -24,8 +24,10 @@
bool
glom_pygda_value_from_pyobject(GValue* boxed, const boost::python::object& input)
{
+std::cout << G_STRFUNC << std::endl;
+
/* Use an appropriate gda_value_set_*() function.
- We can not know what GValue type is actually wanted, so
+ We cannot know what GValue type is actually wanted, so
we must still have the get_*() functions in the python API.
*/
@@ -146,7 +148,7 @@ glom_pygda_value_from_pyobject(GValue* boxed, const boost::python::object& input
//std::cout << "DEBUG Dates not supported." << std::endl;
#endif
- //g_warning("Unhandled python type.");
+ std::cerr << G_STRFUNC << ": Unhandled python type." << std::endl;
return false; /* failed. */
}
diff --git a/glom/python_embed/glom_python.cc b/glom/python_embed/glom_python.cc
index 2483a95..97cb6d9 100644
--- a/glom/python_embed/glom_python.cc
+++ b/glom/python_embed/glom_python.cc
@@ -465,10 +465,21 @@ Gnome::Gda::Value glom_evaluate_python_function_implementation(Field::glom_field
if(object_is_gda_value && G_IS_VALUE(&value))
{
valueResult = Gnome::Gda::Value(&value);
+ if(valueResult.get_value_type() == 0)
+ {
+ std::cerr << G_STRFUNC << ": valueResult (before convert_value()) has a GType of 0 before convert_value()." << std::endl;
+ }
+
//Make sure that the value is of the expected Gda type:
//TODO_Performance:
valueResult = Glom::Conversions::convert_value(valueResult, result_type);
- //std::cout << "DEBUG: glom_evaluate_python_function_implementation(): valueResult Gda type=" << g_type_name(valueResult.get_value_type()) << std::endl;
+
+ if(valueResult.get_value_type() == 0)
+ {
+ std::cerr << G_STRFUNC << ": valueResult has a GType of 0 after convert_value()." << std::endl;
+ }
+
+ //std::cout << "debug: " << G_STRFUNC << ": valueResult Gda type=" << g_type_name(valueResult.get_value_type()) << std::endl;
g_value_unset(&value);
}
else
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]