[glom] Change some uses of long to more appropriate types
- From: David King <davidk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glom] Change some uses of long to more appropriate types
- Date: Mon, 11 Oct 2010 13:24:04 +0000 (UTC)
commit b4f16b8c25bbe27c6f20294ecde3d399db7bda09
Author: David King <davidk openismus com>
Date: Mon Oct 11 15:19:39 2010 +0200
Change some uses of long to more appropriate types
* glom/libglom/python_embed/py_glom_record.[cc|h]:
* glom/libglom/python_embed/py_glom_related.[cc|h]:
* glom/libglom/python_embed/py_glom_relatedrecord.[cc|h]:
* glom/libglom/utils.cc:
* glom/utility_widgets/db_addel/glom_db_treemodel.cc:
* glom/utils_ui.cc: Use other types than long where appropriate.
ChangeLog | 11 +++++++++++
glom/libglom/python_embed/py_glom_record.cc | 2 +-
glom/libglom/python_embed/py_glom_record.h | 8 ++++----
glom/libglom/python_embed/py_glom_related.cc | 2 +-
glom/libglom/python_embed/py_glom_related.h | 2 +-
glom/libglom/python_embed/py_glom_relatedrecord.cc | 2 +-
glom/libglom/python_embed/py_glom_relatedrecord.h | 7 ++++---
glom/libglom/utils.cc | 2 +-
glom/mode_data/datawidget/treemodel_db.cc | 3 ++-
glom/utils_ui.cc | 2 +-
10 files changed, 27 insertions(+), 14 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 8e5acfb..919a5d5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
2010-10-11 David King <davidk openismus com>
+ Change some uses of long to more appropriate types
+
+ * glom/libglom/python_embed/py_glom_record.[cc|h]:
+ * glom/libglom/python_embed/py_glom_related.[cc|h]:
+ * glom/libglom/python_embed/py_glom_relatedrecord.[cc|h]:
+ * glom/libglom/utils.cc:
+ * glom/utility_widgets/db_addel/glom_db_treemodel.cc:
+ * glom/utils_ui.cc: Use other types than long where appropriate.
+
+2010-10-11 David King <davidk openismus com>
+
Use array notation where appropriate
* glom/dialog_connection.[cc|h]:
diff --git a/glom/libglom/python_embed/py_glom_record.cc b/glom/libglom/python_embed/py_glom_record.cc
index 41b8c7f..fe145be 100644
--- a/glom/libglom/python_embed/py_glom_record.cc
+++ b/glom/libglom/python_embed/py_glom_record.cc
@@ -102,7 +102,7 @@ boost::python::object PyGlomRecord::get_related()
return m_related;
}
-long PyGlomRecord::len() const
+PyGlomRecord::type_map_field_values::size_type PyGlomRecord::len() const
{
return m_map_field_values.size();
}
diff --git a/glom/libglom/python_embed/py_glom_record.h b/glom/libglom/python_embed/py_glom_record.h
index 2ace962..4e3ddde 100644
--- a/glom/libglom/python_embed/py_glom_record.h
+++ b/glom/libglom/python_embed/py_glom_record.h
@@ -52,14 +52,14 @@ public:
boost::python::object get_related();
+ //Available, for instance, in python via record["name_first"]
+ typedef std::map<Glib::ustring, Gnome::Gda::Value> type_map_field_values;
+
//[] notation:
- long len() const;
+ type_map_field_values::size_type len() const;
boost::python::object getitem(const boost::python::object& item);
void setitem(const boost::python::object& /* key */, const boost::python::object& /* value */);
- //Available, for instance, in python via record["name_first"]
- typedef std::map<Glib::ustring, Gnome::Gda::Value> type_map_field_values;
-
void set_fields(const PyGlomRecord::type_map_field_values& field_values,
Document* document,
const Glib::ustring& table_name,
diff --git a/glom/libglom/python_embed/py_glom_related.cc b/glom/libglom/python_embed/py_glom_related.cc
index 3e40187..9f6f376 100644
--- a/glom/libglom/python_embed/py_glom_related.cc
+++ b/glom/libglom/python_embed/py_glom_related.cc
@@ -39,7 +39,7 @@ PyGlomRelated::~PyGlomRelated()
}
-long PyGlomRelated::len() const
+PyGlomRelated::type_map_relationships::size_type PyGlomRelated::len() const
{
return m_map_relationships.size();
}
diff --git a/glom/libglom/python_embed/py_glom_related.h b/glom/libglom/python_embed/py_glom_related.h
index b2b024c..3c8e86f 100644
--- a/glom/libglom/python_embed/py_glom_related.h
+++ b/glom/libglom/python_embed/py_glom_related.h
@@ -41,7 +41,7 @@ public:
//[] notation:
- long len() const;
+ type_map_relationships::size_type len() const;
boost::python::object getitem(const boost::python::object& item);
friend class PyGlomRecord;
diff --git a/glom/libglom/python_embed/py_glom_relatedrecord.cc b/glom/libglom/python_embed/py_glom_relatedrecord.cc
index af03525..cb281df 100644
--- a/glom/libglom/python_embed/py_glom_relatedrecord.cc
+++ b/glom/libglom/python_embed/py_glom_relatedrecord.cc
@@ -47,7 +47,7 @@ static void RelatedRecord_HandlePythonError()
PyErr_Print();
}
-long PyGlomRelatedRecord::len() const
+PyGlomRelatedRecord::type_map_field_values::size_type PyGlomRelatedRecord::len() const
{
return m_map_field_values.size();
}
diff --git a/glom/libglom/python_embed/py_glom_relatedrecord.h b/glom/libglom/python_embed/py_glom_relatedrecord.h
index 09b360f..21456f6 100644
--- a/glom/libglom/python_embed/py_glom_relatedrecord.h
+++ b/glom/libglom/python_embed/py_glom_relatedrecord.h
@@ -45,8 +45,11 @@ public:
boost::python::object min(const std::string& field_name) const;
boost::python::object max(const std::string& field_name) const;
+ //Available, for instance, in python via record["name_first"]
+ typedef std::map<Glib::ustring, Gnome::Gda::Value> type_map_field_values;
+
//[] notation:
- long len() const;
+ type_map_field_values::size_type len() const;
boost::python::object getitem(const boost::python::object& item);
private:
@@ -60,8 +63,6 @@ private:
sharedptr<const Relationship> m_relationship;
Gnome::Gda::Value m_from_key_value;
- //Available, for instance, in python via record["name_first"]
- typedef std::map<Glib::ustring, Gnome::Gda::Value> type_map_field_values;
mutable type_map_field_values m_map_field_values; //A cache.
};
diff --git a/glom/libglom/utils.cc b/glom/libglom/utils.cc
index baec8e0..7ab1109 100644
--- a/glom/libglom/utils.cc
+++ b/glom/libglom/utils.cc
@@ -670,7 +670,7 @@ Glib::ustring Utils::create_local_image_uri(const Gnome::Gda::Value& value)
if(value.get_value_type() == GDA_TYPE_BINARY)
{
- glong size = 0;
+ std::streamsize size = 0;
gconstpointer pData = value.get_binary(size);
if(size && pData)
{
diff --git a/glom/mode_data/datawidget/treemodel_db.cc b/glom/mode_data/datawidget/treemodel_db.cc
index d2b550d..95055d9 100644
--- a/glom/mode_data/datawidget/treemodel_db.cc
+++ b/glom/mode_data/datawidget/treemodel_db.cc
@@ -968,7 +968,8 @@ void DbTreeModel::get_record_counts(gulong& total, gulong& found) const
if(datamodel->get_n_rows())
{
Gnome::Gda::Value value = datamodel->get_value_at(0, 0);
- total = (gulong)value.get_int64(); //I discovered that it's a int64 by trying it.
+ // This will probably fail on Windows, where a long is only 32 bits wide.
+ total = static_cast<gulong>(value.get_int64()); //I discovered that it's a int64 by trying it.
}
}
}
diff --git a/glom/utils_ui.cc b/glom/utils_ui.cc
index b711044..8e7a168 100644
--- a/glom/utils_ui.cc
+++ b/glom/utils_ui.cc
@@ -280,7 +280,7 @@ Glib::RefPtr<Gdk::Pixbuf> Utils::get_pixbuf_for_gda_value(const Gnome::Gda::Valu
guint8* puiData = (guint8*)buffer_binary;
try
{
- refPixbufLoader->write(puiData, (glong)buffer_binary_length);
+ refPixbufLoader->write(puiData, static_cast<gsize>(buffer_binary_length));
result = refPixbufLoader->get_pixbuf();
refPixbufLoader->close(); //This throws if write() threw, so it must be inside the try block.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]