replace 'const_xyz' work-arounds in standard .pxd files by real 'const' declarations
authorStefan Behnel <stefan_ml@behnel.de>
Fri, 18 Jan 2013 12:55:38 +0000 (13:55 +0100)
committerStefan Behnel <stefan_ml@behnel.de>
Fri, 18 Jan 2013 12:55:38 +0000 (13:55 +0100)
Cython/Includes/libc/locale.pxd
Cython/Includes/libc/stdio.pxd
Cython/Includes/libc/stdlib.pxd
Cython/Includes/libc/string.pxd
Cython/Includes/libcpp/string.pxd

index 0106bc9..f1f59ff 100644 (file)
@@ -1,7 +1,8 @@
 # 7.11 Localization <locale.h>
 
-cdef extern from *:
-    ctypedef char const_char "const char"
+# deprecated cimport for backwards compatibility:
+from .string cimport const_char
+
 
 cdef extern from "locale.h" nogil:
 
@@ -39,7 +40,7 @@ cdef extern from "locale.h" nogil:
     enum: LC_TIME
 
     # 7.11.1 Locale control
-    char *setlocale (int CATEGORY, const_char *LOCALE)
+    char *setlocale (int CATEGORY, const char *LOCALE)
 
     # 7.11.2 Numeric formatting convention inquiry
     lconv *localeconv ()
index 025378a..93c9f84 100644 (file)
@@ -1,8 +1,9 @@
 # 7.19 Input/output <stdio.h>
 
-cdef extern from *:
-    ctypedef char const_char "const char"
-    ctypedef void const_void "const void"
+
+# deprecated cimports for backwards compatibility:
+from .string cimport const_char, const_void
+
 
 cdef extern from "stdio.h" nogil:
 
@@ -13,11 +14,11 @@ cdef extern from "stdio.h" nogil:
 
     enum: FOPEN_MAX
     enum: FILENAME_MAX
-    FILE *fopen   (const_char *FILENAME, const_char  *OPENTYPE)
-    FILE *freopen (const_char *FILENAME, const_char *OPENTYPE, FILE *STREAM)
+    FILE *fopen   (const char *FILENAME, const char  *OPENTYPE)
+    FILE *freopen (const char *FILENAME, const char *OPENTYPE, FILE *STREAM)
     int  fclose   (FILE *STREAM)
-    int  remove   (const_char *FILENAME)
-    int  rename   (const_char *OLDNAME, const_char *NEWNAME)
+    int  remove   (const char *FILENAME)
+    int  rename   (const char *OLDNAME, const char *NEWNAME)
     FILE *tmpfile ()
 
     enum: _IOFBF
@@ -28,7 +29,7 @@ cdef extern from "stdio.h" nogil:
     void setbuf (FILE *STREAM, char *BUF)
 
     size_t fread  (void *DATA, size_t SIZE, size_t COUNT, FILE *STREAM)
-    size_t fwrite (const_void *DATA, size_t SIZE, size_t COUNT, FILE *STREAM)
+    size_t fwrite (const void *DATA, size_t SIZE, size_t COUNT, FILE *STREAM)
     int    fflush (FILE *STREAM)
 
     enum: EOF
@@ -43,23 +44,23 @@ cdef extern from "stdio.h" nogil:
     long int ftell  (FILE *STREAM)
 
     ctypedef long long int fpos_t
-    ctypedef fpos_t const_fpos_t "const fpos_t"
+    ctypedef const fpos_t const_fpos_t "const fpos_t"
     int fgetpos (FILE *STREAM, fpos_t *POSITION)
-    int fsetpos (FILE *STREAM, const_fpos_t *POSITION)
+    int fsetpos (FILE *STREAM, const fpos_t *POSITION)
 
-    int scanf    (const_char *TEMPLATE, ...)
-    int sscanf   (const_char *S, const_char *TEMPLATE, ...)
-    int fscanf   (FILE *STREAM, const_char *TEMPLATE, ...)
+    int scanf    (const char *TEMPLATE, ...)
+    int sscanf   (const char *S, const char *TEMPLATE, ...)
+    int fscanf   (FILE *STREAM, const char *TEMPLATE, ...)
 
-    int printf   (const_char *TEMPLATE, ...)
-    int sprintf  (char *S, const_char *TEMPLATE, ...)
-    int snprintf (char *S, size_t SIZE, const_char *TEMPLATE, ...)
-    int fprintf  (FILE *STREAM, const_char *TEMPLATE, ...)
+    int printf   (const char *TEMPLATE, ...)
+    int sprintf  (char *S, const char *TEMPLATE, ...)
+    int snprintf (char *S, size_t SIZE, const char *TEMPLATE, ...)
+    int fprintf  (FILE *STREAM, const char *TEMPLATE, ...)
 
-    void perror  (const_char *MESSAGE)
+    void perror  (const char *MESSAGE)
 
     char *gets  (char *S)
     char *fgets (char *S, int COUNT, FILE *STREAM)
 
-    int  puts   (const_char *S)
-    int  fputs  (const_char *S, FILE *STREAM)
+    int  puts   (const char *S)
+    int  fputs  (const char *S, FILE *STREAM)
index a5b8d97..7c2927b 100644 (file)
@@ -1,23 +1,23 @@
 # 7.20 General utilities <stdlib.h>
 
-cdef extern from *:
-    ctypedef char const_char "const char"
-    ctypedef void const_void "const void"
+# deprecated cimports for backwards compatibility:
+from .string cimport const_char, const_void
+
 
 cdef extern from "stdlib.h" nogil:
 
     # 7.20.1 Numeric conversion functions
-    int atoi (const_char *STRING)
-    long atol (const_char *STRING)
-    long long atoll (const_char *STRING)
-    double atof (const_char *STRING)
-    long strtol (const_char *STRING, char **TAILPTR, int BASE)
-    unsigned long int strtoul (const_char *STRING, char **TAILPTR, int BASE)
-    long long int strtoll (const_char *STRING, char **TAILPTR, int BASE)
-    unsigned long long int strtoull (const_char *STRING, char **TAILPTR, int BASE)
-    float strtof (const_char *STRING, char **TAILPTR)
-    double strtod (const_char *STRING, char **TAILPTR)
-    long double strtold (const_char *STRING, char **TAILPTR)
+    int atoi (const char *STRING)
+    long atol (const char *STRING)
+    long long atoll (const char *STRING)
+    double atof (const char *STRING)
+    long strtol (const char *STRING, char **TAILPTR, int BASE)
+    unsigned long int strtoul (const char *STRING, char **TAILPTR, int BASE)
+    long long int strtoll (const char *STRING, char **TAILPTR, int BASE)
+    unsigned long long int strtoull (const char *STRING, char **TAILPTR, int BASE)
+    float strtof (const char *STRING, char **TAILPTR)
+    double strtod (const char *STRING, char **TAILPTR)
+    long double strtold (const char *STRING, char **TAILPTR)
 
     # 7.20.2 Pseudo-random sequence generation functions
     enum: RAND_MAX
@@ -37,15 +37,15 @@ cdef extern from "stdlib.h" nogil:
     void _Exit (int STATUS)
     int atexit (void (*FUNCTION) ())
     void abort ()
-    char *getenv (const_char *NAME)
-    int system (const_char *COMMAND)
+    char *getenv (const char *NAME)
+    int system (const char *COMMAND)
 
     #7.20.5 Searching and sorting utilities
-    void *bsearch (const_void *KEY, const_void *ARRAY,
+    void *bsearch (const void *KEY, const void *ARRAY,
                    size_t COUNT, size_t SIZE,
-                   int (*COMPARE)(const_void *, const_void *))
+                   int (*COMPARE)(const void *, const void *))
     void qsort (void *ARRAY, size_t COUNT, size_t SIZE,
-                int (*COMPARE)(const_void *, const_void *))
+                int (*COMPARE)(const void *, const void *))
 
     # 7.20.6 Integer arithmetic functions
     int abs (int NUMBER)
index fc77a81..8d06227 100644 (file)
@@ -1,48 +1,49 @@
 # 7.21 String handling <string.h>
 
 cdef extern from *:
-    ctypedef char const_char "const char"
-    ctypedef signed char const_schar "const signed char"
-    ctypedef unsigned char const_uchar "const unsigned char"
-    ctypedef void const_void "const void"
+    # deprecated backwards compatibility declarations
+    ctypedef const char const_char "const char"
+    ctypedef const signed char const_schar "const signed char"
+    ctypedef const unsigned char const_uchar "const unsigned char"
+    ctypedef const void const_void "const void"
 
 cdef extern from "string.h" nogil:
 
-    void *memcpy  (void *TO, const_void *FROM, size_t SIZE)
-    void *memmove (void *TO, const_void *FROM, size_t SIZE)
+    void *memcpy  (void *TO, const void *FROM, size_t SIZE)
+    void *memmove (void *TO, const void *FROM, size_t SIZE)
     void *memset  (void *BLOCK, int C, size_t SIZE)
-    int  memcmp   (const_void *A1, const_void *A2, size_t SIZE)
-    void *memchr  (const_void *BLOCK, int C, size_t SIZE)
+    int  memcmp   (const void *A1, const void *A2, size_t SIZE)
+    void *memchr  (const void *BLOCK, int C, size_t SIZE)
 
-    void *memchr  (const_void *BLOCK, int C, size_t SIZE)
-    void *memrchr (const_void *BLOCK, int C, size_t SIZE)
+    void *memchr  (const void *BLOCK, int C, size_t SIZE)
+    void *memrchr (const void *BLOCK, int C, size_t SIZE)
 
-    size_t strlen   (const_char *S)
-    char   *strcpy  (char *TO, const_char *FROM)
-    char   *strncpy (char *TO, const_char *FROM, size_t SIZE)
-    char   *strdup  (const_char *S)
-    char   *strndup (const_char *S, size_t SIZE)
-    char   *strcat  (char *TO, const_char *FROM)
-    char   *strncat (char *TO, const_char *FROM, size_t SIZE)
+    size_t strlen   (const char *S)
+    char   *strcpy  (char *TO, const char *FROM)
+    char   *strncpy (char *TO, const char *FROM, size_t SIZE)
+    char   *strdup  (const char *S)
+    char   *strndup (const char *S, size_t SIZE)
+    char   *strcat  (char *TO, const char *FROM)
+    char   *strncat (char *TO, const char *FROM, size_t SIZE)
 
-    int strcmp (const_char *S1, const_char *S2)
-    int strcasecmp (const_char *S1, const_char *S2)
-    int strncmp (const_char *S1, const_char *S2, size_t SIZE)
-    int strncasecmp (const_char *S1, const_char *S2, size_t N)
+    int strcmp (const char *S1, const char *S2)
+    int strcasecmp (const char *S1, const char *S2)
+    int strncmp (const char *S1, const char *S2, size_t SIZE)
+    int strncasecmp (const char *S1, const char *S2, size_t N)
 
-    int    strcoll (const_char *S1, const_char *S2)
-    size_t strxfrm (char *TO, const_char *FROM, size_t SIZE)
+    int    strcoll (const char *S1, const char *S2)
+    size_t strxfrm (char *TO, const char *FROM, size_t SIZE)
 
     char *strerror (int ERRNUM)
 
-    char *strchr  (const_char *STRING, int C)
-    char *strrchr (const_char *STRING, int C)
+    char *strchr  (const char *STRING, int C)
+    char *strrchr (const char *STRING, int C)
 
-    char *strstr     (const_char *HAYSTACK, const_char *NEEDLE)
-    char *strcasestr (const_char *HAYSTACK, const_char *NEEDLE)
+    char *strstr     (const char *HAYSTACK, const char *NEEDLE)
+    char *strcasestr (const char *HAYSTACK, const char *NEEDLE)
 
-    size_t strcspn (const_char *STRING, const_char *STOPSET)
-    char * strpbrk (const_char *STRING, const_char *STOPSET)
+    size_t strcspn (const char *STRING, const char *STOPSET)
+    char * strpbrk (const char *STRING, const char *STOPSET)
 
-    char *strtok (char *NEWSTRING, const_char *DELIMITERS)
-    char *strsep (char **STRING_PTR, const_char *DELIMITER)
+    char *strtok (char *NEWSTRING, const char *DELIMITERS)
+    char *strsep (char **STRING_PTR, const char *DELIMITER)
index 0505d1b..ac1afcf 100644 (file)
@@ -1,4 +1,7 @@
-from libc.string cimport const_char
+
+# deprecated cimport for backwards compatibility:
+from .string cimport const_char
+
 
 cdef extern from "<string>" namespace "std":
 
@@ -12,8 +15,8 @@ cdef extern from "<string>" namespace "std":
         # as a string formed by a repetition of character c, n times.
         string(size_t, char) nogil except +
 
-        const_char* c_str() nogil
-        const_char* data() nogil
+        const char* c_str() nogil
+        const char* data() nogil
         size_t size() nogil
         size_t max_size() nogil
         size_t length() nogil