home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / py2s152.zip / Include / intobject.h < prev    next >
C/C++ Source or Header  |  1999-06-27  |  4KB  |  101 lines

  1. #ifndef Py_INTOBJECT_H
  2. #define Py_INTOBJECT_H
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6.  
  7. /***********************************************************
  8. Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam,
  9. The Netherlands.
  10.  
  11.                         All Rights Reserved
  12.  
  13. Permission to use, copy, modify, and distribute this software and its
  14. documentation for any purpose and without fee is hereby granted,
  15. provided that the above copyright notice appear in all copies and that
  16. both that copyright notice and this permission notice appear in
  17. supporting documentation, and that the names of Stichting Mathematisch
  18. Centrum or CWI or Corporation for National Research Initiatives or
  19. CNRI not be used in advertising or publicity pertaining to
  20. distribution of the software without specific, written prior
  21. permission.
  22.  
  23. While CWI is the initial source for this software, a modified version
  24. is made available by the Corporation for National Research Initiatives
  25. (CNRI) at the Internet address ftp://ftp.python.org.
  26.  
  27. STICHTING MATHEMATISCH CENTRUM AND CNRI DISCLAIM ALL WARRANTIES WITH
  28. REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
  29. MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH
  30. CENTRUM OR CNRI BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
  31. DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  32. PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  33. TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  34. PERFORMANCE OF THIS SOFTWARE.
  35.  
  36. ******************************************************************/
  37.  
  38. /* Integer object interface */
  39.  
  40. /*
  41. 123456789-123456789-123456789-123456789-123456789-123456789-123456789-12
  42.  
  43. PyIntObject represents a (long) integer.  This is an immutable object;
  44. an integer cannot change its value after creation.
  45.  
  46. There are functions to create new integer objects, to test an object
  47. for integer-ness, and to get the integer value.  The latter functions
  48. returns -1 and sets errno to EBADF if the object is not an PyIntObject.
  49. None of the functions should be applied to nil objects.
  50.  
  51. The type PyIntObject is (unfortunately) exposed here so we can declare
  52. _Py_TrueStruct and _Py_ZeroStruct below; don't use this.
  53. */
  54.  
  55. typedef struct {
  56.     PyObject_HEAD
  57.     long ob_ival;
  58. } PyIntObject;
  59.  
  60. extern DL_IMPORT(PyTypeObject) PyInt_Type;
  61.  
  62. #define PyInt_Check(op) ((op)->ob_type == &PyInt_Type)
  63.  
  64. extern DL_IMPORT(PyObject *) PyInt_FromLong Py_PROTO((long));
  65. extern DL_IMPORT(long) PyInt_AsLong Py_PROTO((PyObject *));
  66. extern DL_IMPORT(long) PyInt_GetMax Py_PROTO((void));
  67.  
  68.  
  69. /*
  70. 123456789-123456789-123456789-123456789-123456789-123456789-123456789-12
  71.  
  72. False and True are special intobjects used by Boolean expressions.
  73. All values of type Boolean must point to either of these; but in
  74. contexts where integers are required they are integers (valued 0 and 1).
  75. Hope these macros don't conflict with other people's.
  76.  
  77. Don't forget to apply Py_INCREF() when returning True or False!!!
  78. */
  79.  
  80. extern DL_IMPORT(PyIntObject) _Py_ZeroStruct, _Py_TrueStruct; /* Don't use these directly */
  81.  
  82. #define Py_False ((PyObject *) &_Py_ZeroStruct)
  83. #define Py_True ((PyObject *) &_Py_TrueStruct)
  84.  
  85. /* Macro, trading safety for speed */
  86. #define PyInt_AS_LONG(op) (((PyIntObject *)(op))->ob_ival)
  87.  
  88. /* These aren't really part of the Int object, but they're handy; the protos
  89.  * are necessary for systems that need the magic of DL_IMPORT and that want
  90.  * to have stropmodule as a dynamically loaded module instead of building it
  91.  * into the main Python shared library/DLL.  Guido thinks I'm weird for
  92.  * building it this way.  :-)  [cjh]
  93.  */
  94. extern DL_IMPORT(unsigned long) PyOS_strtoul Py_PROTO((char *, char **, int));
  95. extern DL_IMPORT(long) PyOS_strtol Py_PROTO((char *, char **, int));
  96.  
  97. #ifdef __cplusplus
  98. }
  99. #endif
  100. #endif /* !Py_INTOBJECT_H */
  101.