Browse Source

Remove (apparently unused) code that is problematic because it references symbols from the generated bindings

rdb 11 years ago
parent
commit
aec80426a3

+ 4 - 0
direct/src/dcparser/dcPacker.cxx

@@ -20,6 +20,10 @@
 #include "dcSwitchParameter.h"
 #include "dcClass.h"
 
+#ifdef HAVE_PYTHON
+#include "py_panda.h"
+#endif
+
 DCPacker::StackElement *DCPacker::StackElement::_deleted_chain = NULL;
 int DCPacker::StackElement::_num_ever_allocated = 0;
 

+ 22 - 182
direct/src/distributed/cConnectionRepository.cxx

@@ -26,11 +26,7 @@
 #include "pStatTimer.h"
 
 #ifdef HAVE_PYTHON
-#ifndef CPPPARSER
-#include "py_panda.h"  
-IMPORT_THIS struct   Dtool_PyTypedObject Dtool_DatagramIterator;
-IMPORT_THIS struct   Dtool_PyTypedObject Dtool_DCClass;
-#endif
+#include "py_panda.h"
 #endif
 
 const string CConnectionRepository::_overflow_event_name = "CRDatagramOverflow";
@@ -42,14 +38,13 @@ PStatCollector CConnectionRepository::_update_pcollector("App:Show code:readerPo
 ////////////////////////////////////////////////////////////////////
 //     Function: CConnectionRepository::Constructor
 //       Access: Published
-//  Description: 
+//  Description:
 ////////////////////////////////////////////////////////////////////
 CConnectionRepository::
 CConnectionRepository(bool has_owner_view, bool threaded_net) :
   _lock("CConnectionRepository::_lock"),
 #ifdef HAVE_PYTHON
   _python_repository(NULL),
-  _python_ai_datagramiterator(NULL),
 #endif
 #ifdef HAVE_OPENSSL
   _http_conn(NULL),
@@ -82,19 +77,12 @@ CConnectionRepository(bool has_owner_view, bool threaded_net) :
   }
 #endif
   _tcp_header_size = tcp_header_size;
-
-#ifdef HAVE_PYTHON
-  PyObject *  PyDitterator = DTool_CreatePyInstance(&_di,Dtool_DatagramIterator,false,false);
-  if(PyDitterator != NULL)
-      _python_ai_datagramiterator = Py_BuildValue("(O)",PyDitterator);
-#endif
-
 }
 
 ////////////////////////////////////////////////////////////////////
 //     Function: CConnectionRepository::Destructor
 //       Access: Published
-//  Description: 
+//  Description:
 ////////////////////////////////////////////////////////////////////
 CConnectionRepository::
 ~CConnectionRepository() {
@@ -182,7 +170,7 @@ try_connect_net(const URLSpec &url) {
 
   disconnect();
 
-  _net_conn = 
+  _net_conn =
     _qcm.open_TCP_client_connection(url.get_server(), url.get_port(),
                                     game_server_timeout_ms);
 
@@ -315,7 +303,7 @@ check_datagram() {
         _msg_channels.push_back(schan);
       }
       _msg_sender = _di.get_uint64();
-      
+
 #ifdef HAVE_PYTHON
       // For now, we need to stuff this field onto the Python
       // structure, to support legacy code that expects to find it
@@ -361,7 +349,7 @@ check_datagram() {
       }
       break;
 #endif  // HAVE_PYTHON
-      
+
     default:
       // Some unknown message; let the caller deal with it.
       return true;
@@ -372,9 +360,6 @@ check_datagram() {
   return false;
 }
 
-
-
-
 ////////////////////////////////////////////////////////////////////
 //     Function: CConnectionRepository::is_connected
 //       Access: Published
@@ -745,7 +730,7 @@ handle_update_field() {
 
   PStatTimer timer(_update_pcollector);
   unsigned int do_id = _di.get_uint32();
-  if (_python_repository != (PyObject *)NULL) 
+  if (_python_repository != (PyObject *)NULL)
   {
     PyObject *doId2do =
       PyObject_GetAttrString(_python_repository, "doId2do");
@@ -794,9 +779,9 @@ handle_update_field() {
       // method might get into trouble if it tried to delete the
       // object from the doId2do map.
       Py_INCREF(distobj);
-      dclass->receive_update(distobj, _di); 
+      dclass->receive_update(distobj, _di);
       Py_DECREF(distobj);
-      
+
       if (PyErr_Occurred()) {
 #if defined(HAVE_THREADS) && !defined(SIMPLE_THREADS)
         PyGILState_Release(gstate);
@@ -810,7 +795,7 @@ handle_update_field() {
 #if defined(HAVE_THREADS) && !defined(SIMPLE_THREADS)
   PyGILState_Release(gstate);
 #endif
-  #endif  // HAVE_PYTHON  
+  #endif  // HAVE_PYTHON
   return true;
 }
 
@@ -880,9 +865,9 @@ handle_update_field_owner() {
         // make a copy of the datagram iterator so that we can use the main
         // iterator for the non-owner update
         DatagramIterator _odi(_di);
-        dclass->receive_update(distobjOV, _odi); 
+        dclass->receive_update(distobjOV, _odi);
         Py_DECREF(distobjOV);
-      
+
         if (PyErr_Occurred()) {
 #if defined(HAVE_THREADS) && !defined(SIMPLE_THREADS)
           PyGILState_Release(gstate);
@@ -919,9 +904,9 @@ handle_update_field_owner() {
         // method might get into trouble if it tried to delete the
         // object from the doId2do map.
         Py_INCREF(distobj);
-        dclass->receive_update(distobj, _di); 
+        dclass->receive_update(distobj, _di);
         Py_DECREF(distobj);
-      
+
         if (PyErr_Occurred()) {
 #if defined(HAVE_THREADS) && !defined(SIMPLE_THREADS)
           PyGILState_Release(gstate);
@@ -935,7 +920,7 @@ handle_update_field_owner() {
 #if defined(HAVE_THREADS) && !defined(SIMPLE_THREADS)
   PyGILState_Release(gstate);
 #endif
-#endif  // HAVE_PYTHON  
+#endif  // HAVE_PYTHON
 
   return true;
 }
@@ -948,17 +933,17 @@ handle_update_field_owner() {
 //               output stream.
 ////////////////////////////////////////////////////////////////////
 void CConnectionRepository::
-describe_message(ostream &out, const string &prefix, 
+describe_message(ostream &out, const string &prefix,
                  const Datagram &dg) const {
   DCPacker packer;
-  
+
   packer.set_unpack_data(dg.get_message());
   CHANNEL_TYPE do_id;
   int msg_type;
   bool is_update = false;
   string full_prefix = "CR::" + prefix;
 
-  if (!_client_datagram) 
+  if (!_client_datagram)
   {
     unsigned char mcnt = packer.raw_unpack_uint8();
     for( ;mcnt > 0; mcnt--)
@@ -967,7 +952,7 @@ describe_message(ostream &out, const string &prefix,
     packer.RAW_UNPACK_CHANNEL();  // msg_sender
     msg_type = packer.raw_unpack_uint16();
     is_update = (msg_type == STATESERVER_OBJECT_UPDATE_FIELD);
-    
+
   } else {
     msg_type = packer.raw_unpack_uint16();
     is_update = (msg_type == CLIENT_OBJECT_UPDATE_FIELD);
@@ -1045,12 +1030,12 @@ describe_message(ostream &out, const string &prefix,
         Py_DECREF(dclass_this);
       }
     }
-    #endif  // HAVE_PYTHON  
+    #endif  // HAVE_PYTHON
 
     int field_id = packer.raw_unpack_uint16();
 
     if (dclass == (DCClass *)NULL) {
-      out << full_prefix << "update for unknown object " << do_id 
+      out << full_prefix << "update for unknown object " << do_id
           << ", field " << field_id << "\n";
 
     } else {
@@ -1059,7 +1044,7 @@ describe_message(ostream &out, const string &prefix,
       DCField *field = dclass->get_field_by_index(field_id);
       if (field == (DCField *)NULL) {
         out << "unknown field " << field_id << "\n";
-        
+
       } else {
         out << field->get_name();
         packer.begin_unpack(field);
@@ -1070,148 +1055,3 @@ describe_message(ostream &out, const string &prefix,
     }
   }
 }
-
-
-
-
-#ifdef HAVE_PYTHON
-#ifdef WANT_NATIVE_NET
-
-bool CConnectionRepository::network_based_reader_and_yielder(PyObject *PycallBackFunction,ClockObject &clock, float returnBy)
-{
-  ReMutexHolder holder(_lock);
-    while(is_connected())
-    {        
-        check_datagram_ai(PycallBackFunction);
-        if(is_connected())
-            _bdc.Flush();
-        float currentTime = clock.get_real_time();
-        float dif_time = returnBy - currentTime;
-        if(dif_time <= 0.001) // to avoi over runs..
-            break;
-        if(is_connected())
-            _bdc.WaitForNetworkReadEvent(dif_time);
-    }
-    return false;
-}
-
-bool CConnectionRepository::check_datagram_ai(PyObject *PycallBackFunction)
-{
-  ReMutexHolder holder(_lock);
-    // these could be static .. not 
-  PyObject *doId2do = NULL; 
-  float startTime =0;
-  float endTime = 0;
-  // this seems weird...here
-  _bdc.Flush();
-  while (_bdc.GetMessage(_dg))
-  { 
-      if (get_verbose()) 
-          describe_message(nout, "RECV", _dg);
-
-      if (_time_warning > 0) 
-        startTime = ClockObject::get_global_clock()->get_real_time();
-
-      // Start breaking apart the datagram.
-      _di.assign(_dg);
-      unsigned char  wc_cnt = _di.get_uint8();
-      _msg_channels.clear();
-      for(unsigned char lp1 = 0; lp1 < wc_cnt; lp1++)
-          _msg_channels.push_back(_di.get_uint64());
-
-      _msg_sender = _di.get_uint64();
-      _msg_type = _di.get_uint16();
-
-      if( _msg_type == STATESERVER_OBJECT_UPDATE_FIELD)
-      {
-          if(doId2do == NULL)
-          {
-              // this is my attemp to take it out of the inner loop  RHH
-              doId2do =PyObject_GetAttrString(_python_repository, "doId2do");
-              nassertr(doId2do != NULL, false);
-          }
-
-          if (!handle_update_field_ai(doId2do)) 
-          {
-              Py_XDECREF(doId2do);
-              if (_time_warning > 0) {
-                endTime = ClockObject::get_global_clock()->get_real_time(); 
-                if ( _time_warning < (endTime - startTime)) {
-                  nout << "msg " << _msg_type <<" from " << _msg_sender << " took "<<  (endTime-startTime) << "secs to process\n";
-                  _dg.dump_hex(nout,2);
-                }
-              }
-              return false; 
-          }
-      }
-      else
-      {
-          PyObject * result = PyEval_CallObject(PycallBackFunction, _python_ai_datagramiterator);
-          if (PyErr_Occurred()) 
-          {        
-              Py_XDECREF(doId2do);
-              if (_time_warning > 0) {
-                endTime = ClockObject::get_global_clock()->get_real_time(); 
-                if ( _time_warning < (endTime - startTime)) {
-                  nout << "msg " << _msg_type <<" from " << _msg_sender << " took "<<  (endTime-startTime) << "secs to process\n";
-                  _dg.dump_hex(nout,2);                
-                }
-              }
-              return true;
-          }
-      }
-
-      if (_time_warning > 0) {
-        endTime = ClockObject::get_global_clock()->get_real_time(); 
-        if ( _time_warning < (endTime - startTime)) {
-          nout << "msg " << _msg_type <<" from " << _msg_sender << " took "<<  (endTime-startTime) << "secs to process\n";
-          _dg.dump_hex(nout,2);   
-        }
-      }
-             
-  }
-
-
-  Py_XDECREF(doId2do);
-  return false;
-}
-
-#endif  // #ifdef WANT_NATIVE_NET
-#endif  // #ifdef HAVE_PYTHON
-
-
-#ifdef HAVE_PYTHON
-#ifdef WANT_NATIVE_NET
-
-
-bool CConnectionRepository::handle_update_field_ai(PyObject *doId2do) 
-{
-  PStatTimer timer(_update_pcollector);
-  unsigned int do_id = _di.get_uint32();
- 
-  PyObject *doId = PyLong_FromUnsignedLong(do_id);
-  PyObject *distobj = PyDict_GetItem(doId2do, doId);
-  Py_DECREF(doId);
-
-  if (distobj != NULL)
-  {
-      PyObject *dclass_obj = PyObject_GetAttrString(distobj, "dclass");
-      nassertr(dclass_obj != NULL, false);
-
-      DCClass *dclass = NULL;
-      DTOOL_Call_ExtractThisPointerForType(dclass_obj, &Dtool_DCClass, (void **) &dclass);
-      if(dclass == NULL)
-          return false;
-
-      Py_INCREF(distobj);
-      dclass->receive_update(distobj, _di); 
-      Py_DECREF(distobj);
-
-      if (PyErr_Occurred()) 
-          return false;
-  }
-  return true;
-}
-
-#endif  // #ifdef WANT_NATIVE_NET
-#endif  // #ifdef HAVE_PYTHON

+ 3 - 17
direct/src/distributed/cConnectionRepository.h

@@ -100,7 +100,7 @@ PUBLISHED:
 #endif
 #ifdef HAVE_NET
   BLOCKING bool try_connect_net(const URLSpec &url);
-  
+
   INLINE QueuedConnectionManager &get_qcm();
   INLINE ConnectionWriter &get_cw();
   INLINE QueuedConnectionReader &get_qcr();
@@ -117,13 +117,7 @@ PUBLISHED:
 #endif
 
   BLOCKING bool check_datagram();
-#ifdef HAVE_PYTHON
-#ifdef WANT_NATIVE_NET
-  BLOCKING bool check_datagram_ai(PyObject *PycallBackFunction);
-  BLOCKING bool network_based_reader_and_yielder(PyObject *PycallBackFunction,ClockObject &clock, float returnBy);
-#endif
-#endif
-    
+
   BLOCKING INLINE void get_datagram(Datagram &dg);
   BLOCKING INLINE void get_datagram_iterator(DatagramIterator &di);
   BLOCKING INLINE CHANNEL_TYPE get_msg_channel(int offset = 0) const;
@@ -167,18 +161,11 @@ PUBLISHED:
   INLINE float get_time_warning() const;
 
 private:
-#ifdef HAVE_PYTHON
-#ifdef WANT_NATIVE_NET
-    bool handle_update_field_ai(PyObject *doId2do);
-#endif
-#endif
-
-
   bool do_check_datagram();
   bool handle_update_field();
   bool handle_update_field_owner();
 
-  void describe_message(ostream &out, const string &prefix, 
+  void describe_message(ostream &out, const string &prefix,
                         const Datagram &dg) const;
 
 private:
@@ -186,7 +173,6 @@ private:
 
 #ifdef HAVE_PYTHON
   PyObject *_python_repository;
-  PyObject *_python_ai_datagramiterator;
 #endif
 
 #ifdef HAVE_OPENSSL