@@ -7,23 +7,65 @@ Python module.
77
88/*[clinic input]
99module _zstd
10- class _zstd.ZstdDecompressor "ZstdDecompressor *" "clinic_state()->ZstdDecompressor_type "
10+ class _zstd.ZstdDecompressor "ZstdDecompressor *" "&zstd_decompressor_type_spec "
1111[clinic start generated code]*/
1212/*[clinic end generated code: output=da39a3ee5e6b4b0d input=4e6eae327c0c0c76]*/
1313
1414#ifndef Py_BUILD_CORE_BUILTIN
1515# define Py_BUILD_CORE_MODULE 1
1616#endif
1717
18- #include "_zstdmodule .h"
18+ #include "Python .h"
1919
20+ #include "_zstdmodule.h"
2021#include "buffer.h"
22+ #include "zstddict.h"
2123
2224#include <stdbool.h> // bool
2325#include <stddef.h> // offsetof()
26+ #include <zstd.h> // ZSTD_*()
27+
28+ typedef struct {
29+ PyObject_HEAD
30+
31+ /* Decompression context */
32+ ZSTD_DCtx * dctx ;
33+
34+ /* ZstdDict object in use */
35+ PyObject * dict ;
36+
37+ /* Unconsumed input data */
38+ char * input_buffer ;
39+ size_t input_buffer_size ;
40+ size_t in_begin , in_end ;
41+
42+ /* Unused data */
43+ PyObject * unused_data ;
44+
45+ /* 0 if decompressor has (or may has) unconsumed input data, 0 or 1. */
46+ char needs_input ;
47+
48+ /* For decompress(), 0 or 1.
49+ 1 when both input and output streams are at a frame edge, means a
50+ frame is completely decoded and fully flushed, or the decompressor
51+ just be initialized. */
52+ char at_frame_edge ;
53+
54+ /* For ZstdDecompressor, 0 or 1.
55+ 1 means the end of the first frame has been reached. */
56+ char eof ;
57+
58+ /* Used for fast reset above three variables */
59+ char _unused_char_for_align ;
60+
61+ /* __init__ has been called, 0 or 1. */
62+ bool initialized ;
63+ } ZstdDecompressor ;
2464
2565#define ZstdDecompressor_CAST (op ) ((ZstdDecompressor *)op)
2666
67+ #include "clinic/decompressor.c.h"
68+
2769static inline ZSTD_DDict *
2870_get_DDict (ZstdDict * self )
2971{
@@ -800,10 +842,6 @@ _zstd_ZstdDecompressor_decompress_impl(ZstdDecompressor *self,
800842 return ret ;
801843}
802844
803- #define clinic_state () (get_zstd_state_from_type(type))
804- #include "clinic/decompressor.c.h"
805- #undef clinic_state
806-
807845static PyMethodDef ZstdDecompressor_methods [] = {
808846 _ZSTD_ZSTDDECOMPRESSOR_DECOMPRESS_METHODDEF
809847 {NULL , NULL }
0 commit comments