adonthell-commits
[Top][All Lists]
Advanced

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

[Adonthell-commits] CVS: adonthell/src/python callback.cc, 1.1.1.1, 1.2


From: Alexandre Courbot <address@hidden>
Subject: [Adonthell-commits] CVS: adonthell/src/python callback.cc, 1.1.1.1, 1.2 callback.h, 1.1.1.1, 1.2 python.cc, 1.1.1.1, 1.2
Date: Thu, 24 Jul 2003 08:58:01 -0400

Update of /cvsroot/adonthell/adonthell/src/python
In directory subversions:/tmp/cvs-serv8178/src/python

Modified Files:
        callback.cc callback.h python.cc 
Log Message:
Applied Fabien's changes and extended them to all the source
(changing using namespace's into real namespace enclosing and fixed some
 consts)


Index: callback.cc
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/python/callback.cc,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -r1.1.1.1 -r1.2
*** callback.cc 18 Jul 2003 15:16:09 -0000      1.1.1.1
--- callback.cc 24 Jul 2003 12:57:59 -0000      1.2
***************
*** 25,27 ****
  #include "python/python.h"
  
! using namespace python;
--- 25,57 ----
  #include "python/python.h"
  
! namespace python
! {
!     functor_base::functor_base (PyObject * c) : callable(c)
!     {
!         Py_INCREF(callable);
!     }
!     
!     functor_base::~functor_base()
!     {
!         Py_DECREF(callable);
!     }
! 
!     functor_0::functor_0 (PyObject * c) : base::functor_0(),
!                                           python::functor_base(c)
!     {
!         *((base::functor_0 *)this) = base::membertranslator_0<functor_0, void 
(functor_0::*)()>(*this, &python::functor_0::run);
!         Py_INCREF(callable);
!     }
! 
!     void functor_0::run()
!     {
!         PyObject * pyres;
!         
!         // We can directly call our function
!         pyres = PyObject_CallObject(callable, NULL);
!         
!         show_traceback();
!         
!         Py_XDECREF(pyres);
!     }
! }

Index: callback.h
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/python/callback.h,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -r1.1.1.1 -r1.2
*** callback.h  18 Jul 2003 15:16:09 -0000      1.1.1.1
--- callback.h  24 Jul 2003 12:57:59 -0000      1.2
***************
*** 42,54 ****
      {
      public:
!         functor_base (PyObject * c) : callable(c)
!         {
!             Py_INCREF(callable);
!         }
! 
!         ~functor_base()
!         {
!             Py_DECREF(callable);
!         }
  
      protected:
--- 42,47 ----
      {
      public:
!         functor_base (PyObject * c);
!         ~functor_base();
  
      protected:
***************
*** 63,85 ****
      {
      public:
!         functor_0 (PyObject * c) : base::functor_0(),
!                                    python::functor_base(c)
!         {
!             *((base::functor_0 *)this) = base::membertranslator_0<functor_0, 
void (functor_0::*)()>(*this, &python::functor_0::run);
!             Py_INCREF(callable);
!         }
  
      private:
!         void run()
!         {
!             PyObject * pyres;
!             
!             // We can directly call our function
!             pyres = PyObject_CallObject(callable, NULL);
!             
!             show_traceback();
!             
!             Py_XDECREF(pyres);
!         }
      };
  
--- 56,63 ----
      {
      public:
!         functor_0 (PyObject * c);
  
      private:
!         void run();
      };
  

Index: python.cc
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/python/python.cc,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -r1.1.1.1 -r1.2
*** python.cc   18 Jul 2003 15:16:09 -0000      1.1.1.1
--- python.cc   24 Jul 2003 12:57:59 -0000      1.2
***************
*** 24,68 ****
  #include "python/python.h"
  
! void python::show_traceback()
  {
!     if ( PyErr_Occurred() )
      {
!         PyErr_Print();
!         fflush (stderr);
      }
- }
  
! void python::init()
! {
!     Py_Initialize();
! }
! 
! void python::cleanup()
! {
!     Py_Finalize();
! }
! 
! bool python::add_search_path(const std::string & path)
! {
!     std::string buf = "import sys; sys.path.insert(0, \"";
!     buf += path;
!     buf += "\")";
! 
!     return run_string(buf);
! }
! 
! bool python::run_string(const std::string & statements)
! {
!     bool ret = PyRun_SimpleString((char *)statements.c_str());
! 
!     show_traceback();
!     return ret;
! }
! 
! PyObject * python::import_module(const std::string & name)
! {
!     PyObject * ret = PyImport_ImportModule((char *)name.c_str());
  
!     show_traceback();
!     return ret;
  }
--- 24,71 ----
  #include "python/python.h"
  
! namespace python
  {
!     void show_traceback()
      {
!         if ( PyErr_Occurred() )
!         {
!             PyErr_Print();
!             fflush (stderr);
!         }
      }
  
!     void init()
!     {
!         Py_Initialize();
!     }
!     
!     void cleanup()
!     {
!         Py_Finalize();
!     }
!     
!     bool add_search_path(const std::string & path)
!     {
!         std::string buf = "import sys; sys.path.insert(0, \"";
!         buf += path;
!         buf += "\")";
!         
!         return run_string(buf);
!     }
!     
!     bool run_string(const std::string & statements)
!     {
!         bool ret = PyRun_SimpleString((char *)statements.c_str());
!         
!         show_traceback();
!         return ret;
!     }
  
!     PyObject * import_module(const std::string & name)
!     {
!         PyObject * ret = PyImport_ImportModule((char *)name.c_str());
!         
!         show_traceback();
!         return ret;
!     }
  }





reply via email to

[Prev in Thread] Current Thread [Next in Thread]