forked from bloomberg/pystack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstring.h
More file actions
112 lines (92 loc) · 1.84 KB
/
string.h
File metadata and controls
112 lines (92 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#pragma once
#include "object.h"
#include <cstdint>
namespace pystack {
typedef uint32_t Py_UCS4;
typedef uint16_t Py_UCS2;
typedef uint8_t Py_UCS1;
typedef Py_UCS4 Py_UNICODE;
typedef Py_ssize_t Py_hash_t;
namespace Python3 {
typedef struct
{
PyObject_VAR_HEAD Py_hash_t ob_shash;
char ob_sval[1];
} PyBytesObject;
} // namespace Python3
namespace Python2 {
typedef struct
{
PyObject_HEAD Py_ssize_t length;
Py_UNICODE* str;
long hash;
PyObject* defenc;
} PyUnicodeObject;
typedef struct
{
PyObject_VAR_HEAD long ob_shash;
int ob_sstate;
char ob_sval[1];
} _PyStringObject;
} // namespace Python2
namespace Python3 {
struct _PyUnicode_State
{
unsigned int interned : 2;
unsigned int kind : 3;
unsigned int compact : 1;
unsigned int ascii : 1;
unsigned int ready : 1;
unsigned int : 24;
};
typedef struct
{
PyObject_HEAD Py_ssize_t length;
Py_hash_t hash;
_PyUnicode_State state;
wchar_t* wstr;
} PyASCIIObject;
typedef struct
{
PyASCIIObject _base;
Py_ssize_t utf8_length;
char* utf8;
Py_ssize_t wstr_length;
} PyCompactUnicodeObject;
typedef struct
{
PyCompactUnicodeObject _base;
union {
void* any;
Py_UCS1* latin1;
Py_UCS2* ucs2;
Py_UCS4* ucs4;
} data;
} PyUnicodeObject;
} // namespace Python3
namespace Python3_12 {
using Python3::_PyUnicode_State;
typedef struct
{
PyObject_HEAD Py_ssize_t length;
Py_hash_t hash;
_PyUnicode_State state;
} PyASCIIObject;
typedef struct
{
PyASCIIObject _base;
Py_ssize_t utf8_length;
char* utf8;
} PyCompactUnicodeObject;
typedef struct
{
PyCompactUnicodeObject _base;
union {
void* any;
Py_UCS1* latin1;
Py_UCS2* ucs2;
Py_UCS4* ucs4;
} data;
} PyUnicodeObject;
} // namespace Python3_12
} // namespace pystack