Skip to content

Commit 2c9c7a5

Browse files
committed
Renamed files bytesobject.[ch] and stringobject.[ch]
Fixed Windows build
1 parent 72b710a commit 2c9c7a5

File tree

10 files changed

+6504
-6504
lines changed

10 files changed

+6504
-6504
lines changed

Include/Python.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565

6666
#include "pydebug.h"
6767

68+
#include "bytearrayobject.h"
6869
#include "bytesobject.h"
6970
#include "unicodeobject.h"
7071
#include "longobject.h"
@@ -75,7 +76,6 @@
7576
#include "complexobject.h"
7677
#endif
7778
#include "rangeobject.h"
78-
#include "stringobject.h"
7979
#include "memoryobject.h"
8080
#include "tupleobject.h"
8181
#include "listobject.h"

Include/bytearrayobject.h

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/* Bytes object interface */
2+
3+
#ifndef Py_BYTESOBJECT_H
4+
#define Py_BYTESOBJECT_H
5+
#ifdef __cplusplus
6+
extern "C" {
7+
#endif
8+
9+
#include <stdarg.h>
10+
11+
/* Type PyByteArrayObject represents a mutable array of bytes.
12+
* The Python API is that of a sequence;
13+
* the bytes are mapped to ints in [0, 256).
14+
* Bytes are not characters; they may be used to encode characters.
15+
* The only way to go between bytes and str/unicode is via encoding
16+
* and decoding.
17+
* For the convenience of C programmers, the bytes type is considered
18+
* to contain a char pointer, not an unsigned char pointer.
19+
*/
20+
21+
/* Object layout */
22+
typedef struct {
23+
PyObject_VAR_HEAD
24+
/* XXX(nnorwitz): should ob_exports be Py_ssize_t? */
25+
int ob_exports; /* how many buffer exports */
26+
Py_ssize_t ob_alloc; /* How many bytes allocated */
27+
char *ob_bytes;
28+
} PyByteArrayObject;
29+
30+
/* Type object */
31+
PyAPI_DATA(PyTypeObject) PyByteArray_Type;
32+
PyAPI_DATA(PyTypeObject) PyByteArrayIter_Type;
33+
34+
/* Type check macros */
35+
#define PyByteArray_Check(self) PyObject_TypeCheck(self, &PyByteArray_Type)
36+
#define PyByteArray_CheckExact(self) (Py_TYPE(self) == &PyByteArray_Type)
37+
38+
/* Direct API functions */
39+
PyAPI_FUNC(PyObject *) PyByteArray_FromObject(PyObject *);
40+
PyAPI_FUNC(PyObject *) PyByteArray_Concat(PyObject *, PyObject *);
41+
PyAPI_FUNC(PyObject *) PyByteArray_FromStringAndSize(const char *, Py_ssize_t);
42+
PyAPI_FUNC(Py_ssize_t) PyByteArray_Size(PyObject *);
43+
PyAPI_FUNC(char *) PyByteArray_AsString(PyObject *);
44+
PyAPI_FUNC(int) PyByteArray_Resize(PyObject *, Py_ssize_t);
45+
46+
/* Macros, trading safety for speed */
47+
#define PyByteArray_AS_STRING(self) (assert(PyByteArray_Check(self)),((PyByteArrayObject *)(self))->ob_bytes)
48+
#define PyByteArray_GET_SIZE(self) (assert(PyByteArray_Check(self)),Py_SIZE(self))
49+
50+
#ifdef __cplusplus
51+
}
52+
#endif
53+
#endif /* !Py_BYTESOBJECT_H */

Include/bytesobject.h

Lines changed: 98 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,111 @@
1-
/* Bytes object interface */
21

3-
#ifndef Py_BYTESOBJECT_H
4-
#define Py_BYTESOBJECT_H
2+
/* String object interface */
3+
4+
#ifndef Py_STRINGOBJECT_H
5+
#define Py_STRINGOBJECT_H
56
#ifdef __cplusplus
67
extern "C" {
78
#endif
89

910
#include <stdarg.h>
1011

11-
/* Type PyByteArrayObject represents a mutable array of bytes.
12-
* The Python API is that of a sequence;
13-
* the bytes are mapped to ints in [0, 256).
14-
* Bytes are not characters; they may be used to encode characters.
15-
* The only way to go between bytes and str/unicode is via encoding
16-
* and decoding.
17-
* For the convenience of C programmers, the bytes type is considered
18-
* to contain a char pointer, not an unsigned char pointer.
19-
*/
20-
21-
/* Object layout */
12+
/*
13+
Type PyBytesObject represents a character string. An extra zero byte is
14+
reserved at the end to ensure it is zero-terminated, but a size is
15+
present so strings with null bytes in them can be represented. This
16+
is an immutable object type.
17+
18+
There are functions to create new string objects, to test
19+
an object for string-ness, and to get the
20+
string value. The latter function returns a null pointer
21+
if the object is not of the proper type.
22+
There is a variant that takes an explicit size as well as a
23+
variant that assumes a zero-terminated string. Note that none of the
24+
functions should be applied to nil objects.
25+
*/
26+
27+
/* Caching the hash (ob_shash) saves recalculation of a string's hash value.
28+
This significantly speeds up dict lookups. */
29+
2230
typedef struct {
2331
PyObject_VAR_HEAD
24-
/* XXX(nnorwitz): should ob_exports be Py_ssize_t? */
25-
int ob_exports; /* how many buffer exports */
26-
Py_ssize_t ob_alloc; /* How many bytes allocated */
27-
char *ob_bytes;
28-
} PyByteArrayObject;
29-
30-
/* Type object */
31-
PyAPI_DATA(PyTypeObject) PyByteArray_Type;
32-
PyAPI_DATA(PyTypeObject) PyByteArrayIter_Type;
33-
34-
/* Type check macros */
35-
#define PyByteArray_Check(self) PyObject_TypeCheck(self, &PyByteArray_Type)
36-
#define PyByteArray_CheckExact(self) (Py_TYPE(self) == &PyByteArray_Type)
37-
38-
/* Direct API functions */
39-
PyAPI_FUNC(PyObject *) PyByteArray_FromObject(PyObject *);
40-
PyAPI_FUNC(PyObject *) PyByteArray_Concat(PyObject *, PyObject *);
41-
PyAPI_FUNC(PyObject *) PyByteArray_FromStringAndSize(const char *, Py_ssize_t);
42-
PyAPI_FUNC(Py_ssize_t) PyByteArray_Size(PyObject *);
43-
PyAPI_FUNC(char *) PyByteArray_AsString(PyObject *);
44-
PyAPI_FUNC(int) PyByteArray_Resize(PyObject *, Py_ssize_t);
45-
46-
/* Macros, trading safety for speed */
47-
#define PyByteArray_AS_STRING(self) (assert(PyByteArray_Check(self)),((PyByteArrayObject *)(self))->ob_bytes)
48-
#define PyByteArray_GET_SIZE(self) (assert(PyByteArray_Check(self)),Py_SIZE(self))
32+
long ob_shash;
33+
char ob_sval[1];
34+
35+
/* Invariants:
36+
* ob_sval contains space for 'ob_size+1' elements.
37+
* ob_sval[ob_size] == 0.
38+
* ob_shash is the hash of the string or -1 if not computed yet.
39+
*/
40+
} PyBytesObject;
41+
42+
PyAPI_DATA(PyTypeObject) PyBytes_Type;
43+
PyAPI_DATA(PyTypeObject) PyBytesIter_Type;
44+
45+
#define PyBytes_Check(op) \
46+
PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_BYTES_SUBCLASS)
47+
#define PyBytes_CheckExact(op) (Py_TYPE(op) == &PyBytes_Type)
48+
49+
PyAPI_FUNC(PyObject *) PyBytes_FromStringAndSize(const char *, Py_ssize_t);
50+
PyAPI_FUNC(PyObject *) PyBytes_FromString(const char *);
51+
PyAPI_FUNC(PyObject *) PyBytes_FromFormatV(const char*, va_list)
52+
Py_GCC_ATTRIBUTE((format(printf, 1, 0)));
53+
PyAPI_FUNC(PyObject *) PyBytes_FromFormat(const char*, ...)
54+
Py_GCC_ATTRIBUTE((format(printf, 1, 2)));
55+
PyAPI_FUNC(Py_ssize_t) PyBytes_Size(PyObject *);
56+
PyAPI_FUNC(char *) PyBytes_AsString(PyObject *);
57+
PyAPI_FUNC(PyObject *) PyBytes_Repr(PyObject *, int);
58+
PyAPI_FUNC(void) PyBytes_Concat(PyObject **, PyObject *);
59+
PyAPI_FUNC(void) PyBytes_ConcatAndDel(PyObject **, PyObject *);
60+
PyAPI_FUNC(int) _PyBytes_Resize(PyObject **, Py_ssize_t);
61+
PyAPI_FUNC(PyObject *) PyBytes_Format(PyObject *, PyObject *);
62+
PyAPI_FUNC(PyObject *) _PyBytes_FormatLong(PyObject*, int, int,
63+
int, char**, int*);
64+
PyAPI_FUNC(PyObject *) PyBytes_DecodeEscape(const char *, Py_ssize_t,
65+
const char *, Py_ssize_t,
66+
const char *);
67+
68+
/* Macro, trading safety for speed */
69+
#define PyBytes_AS_STRING(op) (assert(PyBytes_Check(op)), \
70+
(((PyBytesObject *)(op))->ob_sval))
71+
#define PyBytes_GET_SIZE(op) (assert(PyBytes_Check(op)),Py_SIZE(op))
72+
73+
/* _PyBytes_Join(sep, x) is like sep.join(x). sep must be PyBytesObject*,
74+
x must be an iterable object. */
75+
PyAPI_FUNC(PyObject *) _PyBytes_Join(PyObject *sep, PyObject *x);
76+
77+
/* Provides access to the internal data buffer and size of a string
78+
object or the default encoded version of an Unicode object. Passing
79+
NULL as *len parameter will force the string buffer to be
80+
0-terminated (passing a string with embedded NULL characters will
81+
cause an exception). */
82+
PyAPI_FUNC(int) PyBytes_AsStringAndSize(
83+
register PyObject *obj, /* string or Unicode object */
84+
register char **s, /* pointer to buffer variable */
85+
register Py_ssize_t *len /* pointer to length variable or NULL
86+
(only possible for 0-terminated
87+
strings) */
88+
);
89+
90+
/* Using the current locale, insert the thousands grouping
91+
into the string pointed to by buffer. For the argument descriptions,
92+
see Objects/stringlib/localeutil.h */
93+
94+
PyAPI_FUNC(int) _PyBytes_InsertThousandsGrouping(char *buffer,
95+
Py_ssize_t len,
96+
char *plast,
97+
Py_ssize_t buf_size,
98+
Py_ssize_t *count,
99+
int append_zero_char);
100+
101+
/* Flags used by string formatting */
102+
#define F_LJUST (1<<0)
103+
#define F_SIGN (1<<1)
104+
#define F_BLANK (1<<2)
105+
#define F_ALT (1<<3)
106+
#define F_ZERO (1<<4)
49107

50108
#ifdef __cplusplus
51109
}
52110
#endif
53-
#endif /* !Py_BYTESOBJECT_H */
111+
#endif /* !Py_STRINGOBJECT_H */

Include/stringobject.h

Lines changed: 0 additions & 111 deletions
This file was deleted.

Makefile.pre.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,7 @@ OBJECT_OBJS= \
299299
Objects/abstract.o \
300300
Objects/boolobject.o \
301301
Objects/bytes_methods.o \
302+
Objects/bytearrayobject.o \
302303
Objects/bytesobject.o \
303304
Objects/cellobject.o \
304305
Objects/classobject.o \
@@ -325,7 +326,6 @@ OBJECT_OBJS= \
325326
Objects/rangeobject.o \
326327
Objects/setobject.o \
327328
Objects/sliceobject.o \
328-
Objects/stringobject.o \
329329
Objects/structseq.o \
330330
Objects/tupleobject.o \
331331
Objects/typeobject.o \
@@ -579,6 +579,7 @@ PYTHON_HEADERS= \
579579
Include/bitset.h \
580580
Include/boolobject.h \
581581
Include/bytes_methods.h \
582+
Include/bytearrayobject.h \
582583
Include/bytesobject.h \
583584
Include/cellobject.h \
584585
Include/ceval.h \
@@ -636,7 +637,6 @@ PYTHON_HEADERS= \
636637
Include/rangeobject.h \
637638
Include/setobject.h \
638639
Include/sliceobject.h \
639-
Include/stringobject.h \
640640
Include/structmember.h \
641641
Include/structseq.h \
642642
Include/symtable.h \

0 commit comments

Comments
 (0)