[glom/boostpythonretry] Improvements



commit 7aac3b8f19754b9e530ae4c6987207e63873a9ba
Author: Murray Cumming <murrayc murrayc com>
Date:   Sat Feb 6 14:56:13 2010 +0100

    Improvements

 glom/libglom/python_embed/py_glom_record.cc        |   24 ++++++++-----------
 glom/libglom/python_embed/py_glom_related.cc       |    6 +---
 glom/libglom/python_embed/py_glom_relatedrecord.cc |    6 -----
 glom/python_embed/glom_python.cc                   |    3 +-
 glom/python_embed/python_module/py_glom_module.cc  |    5 +--
 5 files changed, 15 insertions(+), 29 deletions(-)
---
diff --git a/glom/libglom/python_embed/py_glom_record.cc b/glom/libglom/python_embed/py_glom_record.cc
index d83eb77..8776fde 100644
--- a/glom/libglom/python_embed/py_glom_record.cc
+++ b/glom/libglom/python_embed/py_glom_record.cc
@@ -19,13 +19,10 @@
  */
 
 //We need to include this before anything else, to avoid redefinitions:
-#include <Python.h>
-#include <compile.h> /* for the PyCodeObject */
-#include <eval.h> /* for PyEval_EvalCode */
-#include <objimpl.h> /* for PyObject_New() */
+//#include <Python.h>
 
 //#define NO_IMPORT_PYGOBJECT //To avoid a multiple definition in pygtk.
-//#include <pygobject.h> //For the PyGObject and PyGBoxed struct definitions.
+#include <pygobject.h> //For the PyGObject and PyGBoxed struct definitions.
 
 #include <libglom/python_embed/py_glom_record.h>
 #include <libglom/python_embed/py_glom_related.h>
@@ -58,7 +55,9 @@ boost::python::object PyGlomRecord::get_connection()
   
   if(m_connection)
   {
-    PyObject* cobject = 0; //TODO: pygobject_new( G_OBJECT(m_connection->gobj()) ); //Creates a pygda Connection object.
+    //Ask pygobject to create a PyObject* that wraps our GObject, 
+    //presumably using something from pygda:
+    PyObject* cobject = pygobject_new( G_OBJECT(m_connection->gobj()) );
     result = boost::python::object( boost::python::borrowed(cobject) );
   }
   
@@ -71,7 +70,7 @@ boost::python::object PyGlomRecord::get_related()
   if(!m_related)
   {
     //Return a new RelatedRecord:
-    m_related =  boost::python::object(new PyGlomRelated()); //TODO_NotSure
+    m_related = boost::python::object(new PyGlomRelated()); //TODO_NotSure
 
     //Fill it:
     Document::type_vec_relationships vecRelationships = m_document->get_relationships(m_table_name);
@@ -82,14 +81,11 @@ boost::python::object PyGlomRecord::get_related()
         map_relationships[(*iter)->get_name()] = *iter;
     }
 
-    boost::python::extract<PyGlomRelated*> extractor(m_related);
-    if(extractor.check())
-    {
-      PyGlomRelated* related_cpp = extractor;
-      PyGlomRelated_SetRelationships(related_cpp, map_relationships);
+    PyObject* cobject = m_related.ptr();
+    PyGlomRelated* related_cpp = (PyGlomRelated*)(cobject); //TODO: Almost certainly wrong.
+    PyGlomRelated_SetRelationships(related_cpp, map_relationships);
 
-      related_cpp->m_record = boost::python::object(this); //TODO_NotSure
-    }
+    related_cpp->m_record = boost::python::object(this); //TODO_NotSure
   }
 
   return m_related;
diff --git a/glom/libglom/python_embed/py_glom_related.cc b/glom/libglom/python_embed/py_glom_related.cc
index 6ffc240..bd0a9ea 100644
--- a/glom/libglom/python_embed/py_glom_related.cc
+++ b/glom/libglom/python_embed/py_glom_related.cc
@@ -19,10 +19,7 @@
  */
 
 //We need to include this before anything else, to avoid redefinitions:
-#include <Python.h>
-#include <compile.h> /* for the PyCodeObject */
-#include <eval.h> /* for PyEval_EvalCode */
-#include <objimpl.h> /* for PyObject_New() */
+//#include <Python.h>
 
 #include <libglom/python_embed/py_glom_related.h>
 //#include <libglom/python_embed/py_glom_record.h>
@@ -81,6 +78,7 @@ boost::python::object PyGlomRelated::getitem(boost::python::object cppitem)
           sharedptr<Relationship> relationship = iterFind->second;
           const Glib::ustring from_key = relationship->get_from_field();
           
+          //TODO: Wrong? Use ptr()?
           boost::python::extract<PyGlomRecord*> extractor(m_record);
           if(extractor.check())
           {
diff --git a/glom/libglom/python_embed/py_glom_relatedrecord.cc b/glom/libglom/python_embed/py_glom_relatedrecord.cc
index 4537265..4f2c9da 100644
--- a/glom/libglom/python_embed/py_glom_relatedrecord.cc
+++ b/glom/libglom/python_embed/py_glom_relatedrecord.cc
@@ -18,12 +18,6 @@
  * Boston, MA 02111-1307, USA.
  */
 
-//We need to include this before anything else, to avoid redefinitions:
-#include <Python.h>
-#include <compile.h> /* for the PyCodeObject */
-#include <eval.h> /* for PyEval_EvalCode */
-#include <objimpl.h> /* for PyObject_New() */
-
 #include <libglom/python_embed/py_glom_relatedrecord.h>
 #include <libglom/python_embed/py_glom_record.h>
 #include <libglom/python_embed/pygdavalue_conversions.h> //For pygda_value_as_pyobject().
diff --git a/glom/python_embed/glom_python.cc b/glom/python_embed/glom_python.cc
index 0b6a12b..f543d73 100644
--- a/glom/python_embed/glom_python.cc
+++ b/glom/python_embed/glom_python.cc
@@ -333,8 +333,7 @@ Gnome::Gda::Value glom_evaluate_python_function_implementation(Field::glom_field
         bool object_is_gda_value = false;
 
         GValue value = {0, {{0}}};
-        boost::python::handle<> handle(boost::python::borrowed(pyResult));
-        boost::python::object pyResultCpp(handle);
+        boost::python::object pyResultCpp(boost::python::borrowed(pyResult));
         const bool test = glom_pygda_value_from_pyobject(&value, pyResultCpp);
 
         if(test)
diff --git a/glom/python_embed/python_module/py_glom_module.cc b/glom/python_embed/python_module/py_glom_module.cc
index 1dd7c02..4013997 100644
--- a/glom/python_embed/python_module/py_glom_module.cc
+++ b/glom/python_embed/python_module/py_glom_module.cc
@@ -21,9 +21,8 @@
 #include <config.h>
 //We need to include this before anything else, to avoid redefinitions:
 #include <boost/python.hpp>
-#include <compile.h> /* for the PyCodeObject */
-#include <eval.h> /* for PyEval_EvalCode */
-#include <objimpl.h> /* for PyObject_New() */
+//#include <compile.h> /* for the PyCodeObject */
+//#include <eval.h> /* for PyEval_EvalCode */
 
 #include <libglom/python_embed/py_glom_record.h>
 #include <libglom/python_embed/py_glom_related.h>



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]