[Python-checkins] CVS: python/dist/src/Include unicodeobject.h,2.22,2.23

Martin v. L?wis loewis@users.sourceforge.net
Tue, 26 Jun 2001 15:22:39 -0700


Update of /cvsroot/python/python/dist/src/Include
In directory usw-pr-cvs1:/tmp/cvs-serv31084/Include

Modified Files:
	unicodeobject.h 
Log Message:
Support using UCS-4 as the Py_UNICODE type:
Add configure option --enable-unicode.
Add config.h macros Py_USING_UNICODE, PY_UNICODE_TYPE, Py_UNICODE_SIZE,
                    SIZEOF_WCHAR_T.
Define Py_UCS2.
Encode and decode large UTF-8 characters into single Py_UNICODE values
for wide Unicode types; likewise for UTF-16.
Remove test whether sizeof Py_UNICODE is two.


Index: unicodeobject.h
===================================================================
RCS file: /cvsroot/python/python/dist/src/Include/unicodeobject.h,v
retrieving revision 2.22
retrieving revision 2.23
diff -C2 -r2.22 -r2.23
*** unicodeobject.h	2001/06/26 17:17:07	2.22
--- unicodeobject.h	2001/06/26 22:22:37	2.23
***************
*** 61,74 ****
  /* experimental UCS-4 support.  enable at your own risk! */
  #undef USE_UCS4_STORAGE
! 
! /*
!  * Use this typedef when you need to represent a UTF-16 surrogate pair
!  * as single unsigned integer.
!  */
! #if SIZEOF_INT >= 4 
! typedef unsigned int Py_UCS4; 
! #elif SIZEOF_LONG >= 4
! typedef unsigned long Py_UCS4; 
! #endif 
  
  /* Set these flags if the platform has "wchar.h", "wctype.h" and the
--- 61,67 ----
  /* experimental UCS-4 support.  enable at your own risk! */
  #undef USE_UCS4_STORAGE
! #if Py_UNICODE_SIZE == 4
! #define USE_UCS4_STORAGE
! #endif
  
  /* Set these flags if the platform has "wchar.h", "wctype.h" and the
***************
*** 78,86 ****
  
  /* Defaults for various platforms */
! #ifndef HAVE_USABLE_WCHAR_T
  
  /* Windows has a usable wchar_t type (unless we're using UCS-4) */
  # if defined(MS_WIN32) && !defined(USE_UCS4_STORAGE)
  #  define HAVE_USABLE_WCHAR_T
  # endif
  
--- 71,84 ----
  
  /* Defaults for various platforms */
! #ifndef PY_UNICODE_TYPE
  
  /* Windows has a usable wchar_t type (unless we're using UCS-4) */
  # if defined(MS_WIN32) && !defined(USE_UCS4_STORAGE)
  #  define HAVE_USABLE_WCHAR_T
+ #  define PY_UNICODE_TYPE wchar_t
+ # endif
+ 
+ # if defined(USE_UCS4_STORAGE)
+ #  define PY_UNICODE_TYPE Py_UCS4
  # endif
  
***************
*** 104,130 ****
  # include "wchar.h"
  #endif
- 
- #ifdef HAVE_USABLE_WCHAR_T
- 
- /* If the compiler defines whcar_t as a 16-bit unsigned type we can
-    use the compiler type directly.  Works fine with all modern Windows
-    platforms. */
  
! typedef wchar_t Py_UNICODE;
! 
! #else
! 
! /* Use if you have a standard ANSI compiler, without wchar_t support.
!    If a short is not 16 bits on your platform, you have to fix the
!    typedef below, or the module initialization code will complain. */
! 
! #ifdef USE_UCS4_STORAGE
! typedef Py_UCS4 Py_UNICODE;
! #else
! typedef unsigned short Py_UNICODE;
  #endif
  
! #endif
  
  
  /* --- Internal Unicode Operations ---------------------------------------- */
--- 102,123 ----
  # include "wchar.h"
  #endif
  
! /*
!  * Use this typedef when you need to represent a UTF-16 surrogate pair
!  * as single unsigned integer.
!  */
! #if SIZEOF_INT >= 4 
! typedef unsigned int Py_UCS4; 
! #elif SIZEOF_LONG >= 4
! typedef unsigned long Py_UCS4; 
  #endif
  
! #if SIZEOF_SHORT == 2
! typedef unsigned short Py_UCS2;
! #else
! #error Cannot find a two-byte type
! #endif 
  
+ typedef PY_UNICODE_TYPE Py_UNICODE;
  
  /* --- Internal Unicode Operations ---------------------------------------- */