adonthell-commits
[Top][All Lists]
Advanced

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

[Adonthell-commits] CVS: adonthell/src python_class.h,1.7,1.8 python_cla


From: Alexandre Courbot <address@hidden>
Subject: [Adonthell-commits] CVS: adonthell/src python_class.h,1.7,1.8 python_class.cc,1.6,1.7 main.cc,1.40,1.41
Date: Sun, 07 Apr 2002 07:56:34 -0400

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

Modified Files:
        python_class.h python_class.cc main.cc 
Log Message:
FIXED python class bug that prevented -c option to perform correctly.


Index: python_class.h
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/python_class.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -r1.7 -r1.8
*** python_class.h      7 Apr 2002 09:51:28 -0000       1.7
--- python_class.h      7 Apr 2002 11:56:29 -0000       1.8
***************
*** 50,54 ****
       * @return true in case of success, false otherwise.
       */
!     static bool init ();
  
      /**
--- 50,54 ----
       * @return true in case of success, false otherwise.
       */
!     static void init ();
  
      /**
***************
*** 126,129 ****
--- 126,130 ----
      static void put_tuple (PyObject * tuple, ogzstream & file);  
  
+     static PyObject *module;
  private:
      /**
***************
*** 132,137 ****
       */
      static char *python::ptr_to_string (char *c, void *ptr, int sz);
- 
-     static PyObject *module;
  };
  
--- 133,136 ----

Index: python_class.cc
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/python_class.cc,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -r1.6 -r1.7
*** python_class.cc     7 Apr 2002 09:51:28 -0000       1.6
--- python_class.cc     7 Apr 2002 11:56:29 -0000       1.7
***************
*** 33,83 ****
  
  /*
-  * SWIG init prototypes. Should we use dynamic linking??? 
-  */
- extern "C"
- {
-     /** 
-      * SWIG init prototype.
-      * 
-      */
-     void initadonthellc (void);
- }
- 
- /*
   * Start Python
   */
! bool python::init ()
  {
      Py_Initialize ();
-     
-     // Initialise the import path.
-     // Shared modules path 
-     insert_path (DATA_DIR"/modules"); 
- 
-     // Game specific path
-     string t = game::game_data_dir () + "/scripts/modules"; 
-     insert_path ((char *) t.c_str ());
-     t = game::game_data_dir () + "/scripts"; 
-     insert_path ((char *) t.c_str ());
- 
-     // Initialise SWIG module. This should go if we ever switch 
-     // to dynamic linking
-     initadonthellc ();
-         
-     module = import_module ("adonthell"); 
-     if (!module) return false;     
-     
-     data::globals = PyModule_GetDict (module);
- 
-     return true; 
  }
  
  void python::cleanup () 
! {     
!     // Cleanup the global namespace of python interpreter
!     // Note that we don't have to DECREF data::globals, because they're a
!     // borrowed reference of py_module.
!     Py_DECREF (module); 
! 
      Py_Finalize ();
  }
--- 33,45 ----
  
  /*
   * Start Python
   */
! void python::init ()
  {
      Py_Initialize ();
  }
  
  void python::cleanup () 
! {
      Py_Finalize ();
  }

Index: main.cc
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/main.cc,v
retrieving revision 1.40
retrieving revision 1.41
diff -C2 -r1.40 -r1.41
*** main.cc     7 Apr 2002 09:51:28 -0000       1.40
--- main.cc     7 Apr 2002 11:56:29 -0000       1.41
***************
*** 39,42 ****
--- 39,78 ----
  using namespace std; 
  
+ /*
+  * SWIG init prototypes. Should we use dynamic linking??? 
+  */
+ extern "C"
+ {
+     /** 
+      * SWIG init prototype.
+      * 
+      */
+     void initadonthellc (void);
+ }
+ 
+ bool init_python()
+ {
+     // Initialise the import path.
+     // Shared modules path 
+     python::insert_path (DATA_DIR"/modules"); 
+     
+     // Game specific path
+     string t = game::game_data_dir () + "/scripts/modules"; 
+     python::insert_path ((char *) t.c_str ());
+     t = game::game_data_dir () + "/scripts"; 
+     python::insert_path ((char *) t.c_str ());
+     
+     // Initialise SWIG module. This should go if we ever switch 
+     // to dynamic linking
+     initadonthellc ();
+     
+     python::module = python::import_module ("adonthell"); 
+     if (!python::module) return false;     
+     
+     data::globals = PyModule_GetDict (python::module);
+     
+     return true; 
+ }
+ 
  /**
   * Game's main function.
***************
*** 51,55 ****
   * 
   */
- 
  int main(int argc, char * argv[])
  {
--- 87,90 ----
***************
*** 87,90 ****
--- 122,126 ----
      python::init (); 
  
+     init_python();
      // init the game data
      data::engine = new adonthell;
***************
*** 116,119 ****
--- 152,159 ----
  
      // shutdown python
+     // Cleanup the global namespace of python interpreter
+     // Note that we don't have to DECREF data::globals, because they're a
+     // borrowed reference of py_module.
+     Py_DECREF (python::module); 
      python::cleanup ();     
  




reply via email to

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