[Python-checkins] python/dist/src/Doc/ext newtypes.tex,1.24,1.25

dcjim@users.sourceforge.net dcjim@users.sourceforge.net
Fri, 16 May 2003 06:33:01 -0700


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

Modified Files:
	newtypes.tex 
Log Message:
Removed reference to the out-of-date (and not very useful)
Objects/xxobject.c example.

Updated the discussion of type checking to refer to
PyObject_TypeCheck.


Index: newtypes.tex
===================================================================
RCS file: /cvsroot/python/python/dist/src/Doc/ext/newtypes.tex,v
retrieving revision 1.24
retrieving revision 1.25
diff -C2 -d -r1.24 -r1.25
*** newtypes.tex	8 May 2003 10:35:07 -0000	1.24
--- newtypes.tex	16 May 2003 13:32:59 -0000	1.25
***************
*** 1335,1349 ****
  
  Remember that you can omit most of these functions, in which case you
! provide \code{0} as a value.
! 
! In the \file{Objects} directory of the Python source distribution,
! there is a file \file{xxobject.c}, which is intended to be used as a
! template for the implementation of new types.  One useful strategy
! for implementing a new type is to copy and rename this file, then
! read the instructions at the top of it.
! 
! There are type definitions for each of the functions you must
! provide.  They are in \file{object.h} in the Python include
! directory that comes with the source distribution of Python.
  
  In order to learn how to implement any specific method for your new
--- 1335,1342 ----
  
  Remember that you can omit most of these functions, in which case you
! provide \code{0} as a value.  There are type definitions for each of
! the functions you must provide.  They are in \file{object.h} in the
! Python include directory that comes with the source distribution of
! Python.
  
  In order to learn how to implement any specific method for your new
***************
*** 1354,1371 ****
  examples of the function you want to implement.
  
! When you need to verify that the type of an object is indeed the
! object you are implementing and if you use xxobject.c as an starting
! template for your implementation, then there is a macro defined for
! this purpose. The macro definition will look something like this:
! 
! \begin{verbatim}
! #define is_newdatatypeobject(v)  ((v)->ob_type == &Newdatatypetype)
! \end{verbatim}
! 
! And, a sample of its use might be something like the following:
  
  \begin{verbatim}
!     if (!is_newdatatypeobject(objp1) {
!         PyErr_SetString(PyExc_TypeError, "arg #1 not a newdatatype");
          return NULL;
      }
--- 1347,1357 ----
  examples of the function you want to implement.
  
! When you need to verify that an object is an instance of the type
! you are implementing, use the \cfunction{PyObject_TypeCheck} function.
! A sample of its use might be something like the following:
  
  \begin{verbatim}
!     if (! PyObject_TypeCheck(some_object, &MyType) {
!         PyErr_SetString(PyExc_TypeError, "arg #1 not a mything");
          return NULL;
      }