Mercurial > cpython-lru_cache-weakref
annotate Include/cStringIO.h @ 23150:52257affe0c9 2.2
backport gvanrossum's patch:
Deprecate % as well. The message for deprecation of //, % and divmod
is the same in all three cases (mostly because // calls divmod :-).
Original patches were:
python/dist/src/Objects/complexobject.c:2.59
| author | Anthony Baxter <anthonybaxter@gmail.com> |
|---|---|
| date | Thu, 18 Apr 2002 05:39:54 +0000 |
| parents | ac5489a2548d |
| children | c0596f84a8fb |
| rev | line source |
|---|---|
| 4598 | 1 #ifndef CSTRINGIO_INCLUDED |
| 2 #define CSTRINGIO_INCLUDED | |
| 3 /* | |
| 4 | |
|
6775
3117af9dbfce
Remove the last bits of log from the leading comments.
Guido van Rossum <guido@python.org>
parents:
6741
diff
changeset
|
5 cStringIO.h,v 1.4 1997/12/07 14:27:00 jim Exp |
| 4598 | 6 |
| 7 cStringIO C API | |
| 8 | |
| 9 Copyright | |
| 10 | |
| 11 Copyright 1996 Digital Creations, L.C., 910 Princess Anne | |
| 12 Street, Suite 300, Fredericksburg, Virginia 22401 U.S.A. All | |
| 13 rights reserved. Copyright in this software is owned by DCLC, | |
| 14 unless otherwise indicated. Permission to use, copy and | |
| 15 distribute this software is hereby granted, provided that the | |
| 16 above copyright notice appear in all copies and that both that | |
| 17 copyright notice and this permission notice appear. Note that | |
| 18 any product, process or technology described in this software | |
| 19 may be the subject of other Intellectual Property rights | |
| 20 reserved by Digital Creations, L.C. and are not licensed | |
| 21 hereunder. | |
| 22 | |
| 23 Trademarks | |
| 24 | |
| 25 Digital Creations & DCLC, are trademarks of Digital Creations, L.C.. | |
| 26 All other trademarks are owned by their respective companies. | |
| 27 | |
| 28 No Warranty | |
| 29 | |
| 30 The software is provided "as is" without warranty of any kind, | |
| 31 either express or implied, including, but not limited to, the | |
| 32 implied warranties of merchantability, fitness for a particular | |
| 33 purpose, or non-infringement. This software could include | |
| 34 technical inaccuracies or typographical errors. Changes are | |
| 35 periodically made to the software; these changes will be | |
| 36 incorporated in new editions of the software. DCLC may make | |
| 37 improvements and/or changes in this software at any time | |
| 38 without notice. | |
| 39 | |
| 40 Limitation Of Liability | |
| 41 | |
| 42 In no event will DCLC be liable for direct, indirect, special, | |
| 43 incidental, economic, cover, or consequential damages arising | |
| 44 out of the use of or inability to use this software even if | |
| 45 advised of the possibility of such damages. Some states do not | |
| 46 allow the exclusion or limitation of implied warranties or | |
| 47 limitation of liability for incidental or consequential | |
| 48 damages, so the above limitation or exclusion may not apply to | |
| 49 you. | |
| 50 | |
| 51 If you have questions regarding this software, | |
| 52 contact: | |
| 53 | |
| 54 info@digicool.com | |
| 55 Digital Creations L.C. | |
| 56 | |
| 57 (540) 371-6909 | |
| 58 | |
| 59 | |
| 60 This header provides access to cStringIO objects from C. | |
| 61 Functions are provided for calling cStringIO objects and | |
| 62 macros are provided for testing whether you have cStringIO | |
| 63 objects. | |
| 64 | |
| 65 Before calling any of the functions or macros, you must initialize | |
| 66 the routines with: | |
| 67 | |
|
9944
396a38ea9b84
There's a macro PycString_IMPORT which the documentation listed as
Guido van Rossum <guido@python.org>
parents:
9605
diff
changeset
|
68 PycString_IMPORT |
| 4598 | 69 |
| 70 This would typically be done in your init function. | |
| 71 | |
| 72 */ | |
| 73 | |
|
13620
5b727ab37092
Spelling fixes supplied by Rob W. W. Hooft. All these are fixes in either
Thomas Wouters <thomas@python.org>
parents:
13447
diff
changeset
|
74 /* Basic functions to manipulate cStringIO objects from C */ |
| 4598 | 75 |
|
5279
16372a4c4c14
Changed the way the C API was exported. Jim Fulton.
Guido van Rossum <guido@python.org>
parents:
4902
diff
changeset
|
76 static struct PycStringIO_CAPI { |
|
16372a4c4c14
Changed the way the C API was exported. Jim Fulton.
Guido van Rossum <guido@python.org>
parents:
4902
diff
changeset
|
77 |
|
16372a4c4c14
Changed the way the C API was exported. Jim Fulton.
Guido van Rossum <guido@python.org>
parents:
4902
diff
changeset
|
78 /* Read a string. If the last argument is -1, the remainder will be read. */ |
|
13447
a89f7f268de4
Nuke all remaining occurrences of Py_PROTO and Py_FPROTO.
Tim Peters <tim.peters@gmail.com>
parents:
9944
diff
changeset
|
79 int(*cread)(PyObject *, char **, int); |
| 4598 | 80 |
|
5279
16372a4c4c14
Changed the way the C API was exported. Jim Fulton.
Guido van Rossum <guido@python.org>
parents:
4902
diff
changeset
|
81 /* Read a line */ |
|
13447
a89f7f268de4
Nuke all remaining occurrences of Py_PROTO and Py_FPROTO.
Tim Peters <tim.peters@gmail.com>
parents:
9944
diff
changeset
|
82 int(*creadline)(PyObject *, char **); |
| 4598 | 83 |
|
5279
16372a4c4c14
Changed the way the C API was exported. Jim Fulton.
Guido van Rossum <guido@python.org>
parents:
4902
diff
changeset
|
84 /* Write a string */ |
|
13447
a89f7f268de4
Nuke all remaining occurrences of Py_PROTO and Py_FPROTO.
Tim Peters <tim.peters@gmail.com>
parents:
9944
diff
changeset
|
85 int(*cwrite)(PyObject *, char *, int); |
| 4598 | 86 |
|
5279
16372a4c4c14
Changed the way the C API was exported. Jim Fulton.
Guido van Rossum <guido@python.org>
parents:
4902
diff
changeset
|
87 /* Get the cStringIO object as a Python string */ |
|
13447
a89f7f268de4
Nuke all remaining occurrences of Py_PROTO and Py_FPROTO.
Tim Peters <tim.peters@gmail.com>
parents:
9944
diff
changeset
|
88 PyObject *(*cgetvalue)(PyObject *); |
| 4598 | 89 |
|
5279
16372a4c4c14
Changed the way the C API was exported. Jim Fulton.
Guido van Rossum <guido@python.org>
parents:
4902
diff
changeset
|
90 /* Create a new output object */ |
|
13447
a89f7f268de4
Nuke all remaining occurrences of Py_PROTO and Py_FPROTO.
Tim Peters <tim.peters@gmail.com>
parents:
9944
diff
changeset
|
91 PyObject *(*NewOutput)(int); |
| 4598 | 92 |
|
5279
16372a4c4c14
Changed the way the C API was exported. Jim Fulton.
Guido van Rossum <guido@python.org>
parents:
4902
diff
changeset
|
93 /* Create an input object from a Python string */ |
|
13447
a89f7f268de4
Nuke all remaining occurrences of Py_PROTO and Py_FPROTO.
Tim Peters <tim.peters@gmail.com>
parents:
9944
diff
changeset
|
94 PyObject *(*NewInput)(PyObject *); |
| 4598 | 95 |
|
5279
16372a4c4c14
Changed the way the C API was exported. Jim Fulton.
Guido van Rossum <guido@python.org>
parents:
4902
diff
changeset
|
96 /* The Python types for cStringIO input and output objects. |
|
16372a4c4c14
Changed the way the C API was exported. Jim Fulton.
Guido van Rossum <guido@python.org>
parents:
4902
diff
changeset
|
97 Note that you can do input on an output object. |
|
16372a4c4c14
Changed the way the C API was exported. Jim Fulton.
Guido van Rossum <guido@python.org>
parents:
4902
diff
changeset
|
98 */ |
|
16372a4c4c14
Changed the way the C API was exported. Jim Fulton.
Guido van Rossum <guido@python.org>
parents:
4902
diff
changeset
|
99 PyTypeObject *InputType, *OutputType; |
|
16372a4c4c14
Changed the way the C API was exported. Jim Fulton.
Guido van Rossum <guido@python.org>
parents:
4902
diff
changeset
|
100 |
|
16372a4c4c14
Changed the way the C API was exported. Jim Fulton.
Guido van Rossum <guido@python.org>
parents:
4902
diff
changeset
|
101 } * PycStringIO = NULL; |
| 4598 | 102 |
| 103 /* These can be used to test if you have one */ | |
| 4902 | 104 #define PycStringIO_InputCheck(O) \ |
|
5279
16372a4c4c14
Changed the way the C API was exported. Jim Fulton.
Guido van Rossum <guido@python.org>
parents:
4902
diff
changeset
|
105 ((O)->ob_type==PycStringIO->InputType) |
| 4902 | 106 #define PycStringIO_OutputCheck(O) \ |
|
5279
16372a4c4c14
Changed the way the C API was exported. Jim Fulton.
Guido van Rossum <guido@python.org>
parents:
4902
diff
changeset
|
107 ((O)->ob_type==PycStringIO->OutputType) |
| 4598 | 108 |
|
9605
6b59f9ab5db1
Undo the change here -- there's no point in declaring a static
Guido van Rossum <guido@python.org>
parents:
9586
diff
changeset
|
109 static void * |
|
13660
a1ce07218781
Miscelaneous ANSIfications. I'm assuming here 'main' should take (int,
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
110 xxxPyCObject_Import(char *module_name, char *name) |
|
5991
a5737dd96979
cPickle release 0.3 from Jim Fulton
Guido van Rossum <guido@python.org>
parents:
5284
diff
changeset
|
111 { |
|
a5737dd96979
cPickle release 0.3 from Jim Fulton
Guido van Rossum <guido@python.org>
parents:
5284
diff
changeset
|
112 PyObject *m, *c; |
|
a5737dd96979
cPickle release 0.3 from Jim Fulton
Guido van Rossum <guido@python.org>
parents:
5284
diff
changeset
|
113 void *r=NULL; |
|
a5737dd96979
cPickle release 0.3 from Jim Fulton
Guido van Rossum <guido@python.org>
parents:
5284
diff
changeset
|
114 |
|
a5737dd96979
cPickle release 0.3 from Jim Fulton
Guido van Rossum <guido@python.org>
parents:
5284
diff
changeset
|
115 if((m=PyImport_ImportModule(module_name))) |
|
a5737dd96979
cPickle release 0.3 from Jim Fulton
Guido van Rossum <guido@python.org>
parents:
5284
diff
changeset
|
116 { |
|
a5737dd96979
cPickle release 0.3 from Jim Fulton
Guido van Rossum <guido@python.org>
parents:
5284
diff
changeset
|
117 if((c=PyObject_GetAttrString(m,name))) |
|
a5737dd96979
cPickle release 0.3 from Jim Fulton
Guido van Rossum <guido@python.org>
parents:
5284
diff
changeset
|
118 { |
|
a5737dd96979
cPickle release 0.3 from Jim Fulton
Guido van Rossum <guido@python.org>
parents:
5284
diff
changeset
|
119 r=PyCObject_AsVoidPtr(c); |
|
a5737dd96979
cPickle release 0.3 from Jim Fulton
Guido van Rossum <guido@python.org>
parents:
5284
diff
changeset
|
120 Py_DECREF(c); |
|
a5737dd96979
cPickle release 0.3 from Jim Fulton
Guido van Rossum <guido@python.org>
parents:
5284
diff
changeset
|
121 } |
|
a5737dd96979
cPickle release 0.3 from Jim Fulton
Guido van Rossum <guido@python.org>
parents:
5284
diff
changeset
|
122 Py_DECREF(m); |
|
a5737dd96979
cPickle release 0.3 from Jim Fulton
Guido van Rossum <guido@python.org>
parents:
5284
diff
changeset
|
123 } |
|
a5737dd96979
cPickle release 0.3 from Jim Fulton
Guido van Rossum <guido@python.org>
parents:
5284
diff
changeset
|
124 |
|
a5737dd96979
cPickle release 0.3 from Jim Fulton
Guido van Rossum <guido@python.org>
parents:
5284
diff
changeset
|
125 return r; |
|
a5737dd96979
cPickle release 0.3 from Jim Fulton
Guido van Rossum <guido@python.org>
parents:
5284
diff
changeset
|
126 } |
|
a5737dd96979
cPickle release 0.3 from Jim Fulton
Guido van Rossum <guido@python.org>
parents:
5284
diff
changeset
|
127 |
| 4598 | 128 #define PycString_IMPORT \ |
|
18064
ac5489a2548d
Cast the result of xxxPyCObject_Import to PycStringIO_CAPI*.
Martin v. Löwis <martin@v.loewis.de>
parents:
13660
diff
changeset
|
129 PycStringIO=(struct PycStringIO_CAPI*)xxxPyCObject_Import("cStringIO", "cStringIO_CAPI") |
| 4598 | 130 |
| 131 #endif /* CSTRINGIO_INCLUDED */ |
