[Python-checkins] python/dist/src/Doc/ext newtypes.tex,1.27,1.28

dcjim@users.sourceforge.net dcjim@users.sourceforge.net
Sat, 28 Jun 2003 04:53:14 -0700


Update of /cvsroot/python/python/dist/src/Doc/ext
In directory sc8-pr-cvs1:/tmp/cvs-serv18456a

Modified Files:
	newtypes.tex 
Log Message:
Changed the assignment of PyType_GenericNew to tp_new slot. Now do
this in module initialization before calling PyType_Ready.  (Sorry
Tim.) This is necessary to compile on cygwin.  AFAIK, we support
cygwin. If so, then we need to write extentions this way.

Fixed bug in implementation of tp_init function. It should be an int
function, not a PyObject *.


Index: newtypes.tex
===================================================================
RCS file: /cvsroot/python/python/dist/src/Doc/ext/newtypes.tex,v
retrieving revision 1.27
retrieving revision 1.28
diff -C2 -d -r1.27 -r1.28
*** newtypes.tex	16 May 2003 14:36:26 -0000	1.27
--- newtypes.tex	28 Jun 2003 11:53:12 -0000	1.28
***************
*** 100,120 ****
      Py_TPFLAGS_DEFAULT,        /*tp_flags*/
      "Noddy objects",           /* tp_doc */
-     0,		               /* tp_traverse */
-     0,		               /* tp_clear */
-     0,		               /* tp_richcompare */
-     0,		               /* tp_weaklistoffset */
-     0,		               /* tp_iter */
-     0,		               /* tp_iternext */
-     0,		               /* tp_methods */
-     0,                         /* tp_members */
-     0,                         /* tp_getset */
-     0,                         /* tp_base */
-     0,                         /* tp_dict */
-     0,                         /* tp_descr_get */
-     0,                         /* tp_descr_set */
-     0,                         /* tp_dictoffset */
-     0,                         /* tp_init */
-     0,                         /* tp_alloc */
-     PyType_GenericNew,         /* tp_new */
  };
  \end{verbatim}
--- 100,103 ----
***************
*** 210,217 ****
  \member{tp_new} implementation. In this case, we can just use the
  default implementation provided by the API function
! \cfunction{PyType_GenericNew}.
  
  \begin{verbatim}
!     PyType_GenericNew,         /* tp_new */
  \end{verbatim}
  
--- 193,207 ----
  \member{tp_new} implementation. In this case, we can just use the
  default implementation provided by the API function
! \cfunction{PyType_GenericNew}.  We'd like to just assign this to the
! \member{tp_new} slot, but we can't, for portability sake, On some
! platforms or compilers, we can't statically initialize a structure
! member with a function defined in another C module, so, instead, we'll
! assign the \member{tp_new} slot in the module initialization function
! just before calling \cfunction{PyType_Ready()}:
  
  \begin{verbatim}
!     noddy_NoddyType.tp_new = PyType_GenericNew;
!     if (PyType_Ready(&noddy_NoddyType) < 0)
!         return;
  \end{verbatim}
  
***************
*** 398,402 ****
  
  \begin{verbatim}
! static PyObject *
  Noddy_init(Noddy *self, PyObject *args, PyObject *kwds)
  {
--- 388,392 ----
  
  \begin{verbatim}
! static int
  Noddy_init(Noddy *self, PyObject *args, PyObject *kwds)
  {
***************
*** 408,412 ****
                                        &first, &last, 
                                        &self->number))
!         return NULL; 
  
      if (first) {
--- 398,402 ----
                                        &first, &last, 
                                        &self->number))
!         return -1; 
  
      if (first) {
***************
*** 422,427 ****
      }
  
!     Py_INCREF(Py_None);
!     return Py_None;
  }
  \end{verbatim}
--- 412,416 ----
      }
  
!     return 0;
  }
  \end{verbatim}