@@ -28,45 +28,31 @@ typedef struct unpack_user {
2828 const char * unicode_errors ;
2929} unpack_user ;
3030
31+ typedef PyObject * msgpack_unpack_object ;
32+ struct unpack_context ;
33+ typedef struct unpack_context unpack_context ;
34+ typedef int (* execute_fn )(unpack_context * ctx , const char * data , size_t len , size_t * off );
3135
32- #define msgpack_unpack_struct (name ) \
33- struct template ## name
34-
35- #define msgpack_unpack_func (ret , name ) \
36- static inline ret template ## name
37-
38- #define msgpack_unpack_callback (name ) \
39- template_callback ## name
40-
41- #define msgpack_unpack_object PyObject*
42-
43- #define msgpack_unpack_user unpack_user
44-
45- typedef int (* execute_fn )(msgpack_unpack_struct (_context )* ctx , const char * data , size_t len , size_t * off );
46-
47- struct template_context ;
48- typedef struct template_context template_context ;
49-
50- static inline msgpack_unpack_object template_callback_root (unpack_user * u )
36+ static inline msgpack_unpack_object unpack_callback_root (unpack_user * u )
5137{
5238 return NULL ;
5339}
5440
55- static inline int template_callback_uint16 (unpack_user * u , uint16_t d , msgpack_unpack_object * o )
41+ static inline int unpack_callback_uint16 (unpack_user * u , uint16_t d , msgpack_unpack_object * o )
5642{
5743 PyObject * p = PyInt_FromLong ((long )d );
5844 if (!p )
5945 return -1 ;
6046 * o = p ;
6147 return 0 ;
6248}
63- static inline int template_callback_uint8 (unpack_user * u , uint8_t d , msgpack_unpack_object * o )
49+ static inline int unpack_callback_uint8 (unpack_user * u , uint8_t d , msgpack_unpack_object * o )
6450{
65- return template_callback_uint16 (u , d , o );
51+ return unpack_callback_uint16 (u , d , o );
6652}
6753
6854
69- static inline int template_callback_uint32 (unpack_user * u , uint32_t d , msgpack_unpack_object * o )
55+ static inline int unpack_callback_uint32 (unpack_user * u , uint32_t d , msgpack_unpack_object * o )
7056{
7157 PyObject * p ;
7258 if (d > LONG_MAX ) {
@@ -80,7 +66,7 @@ static inline int template_callback_uint32(unpack_user* u, uint32_t d, msgpack_u
8066 return 0 ;
8167}
8268
83- static inline int template_callback_uint64 (unpack_user * u , uint64_t d , msgpack_unpack_object * o )
69+ static inline int unpack_callback_uint64 (unpack_user * u , uint64_t d , msgpack_unpack_object * o )
8470{
8571 PyObject * p = PyLong_FromUnsignedLongLong (d );
8672 if (!p )
@@ -89,7 +75,7 @@ static inline int template_callback_uint64(unpack_user* u, uint64_t d, msgpack_u
8975 return 0 ;
9076}
9177
92- static inline int template_callback_int32 (unpack_user * u , int32_t d , msgpack_unpack_object * o )
78+ static inline int unpack_callback_int32 (unpack_user * u , int32_t d , msgpack_unpack_object * o )
9379{
9480 PyObject * p = PyInt_FromLong (d );
9581 if (!p )
@@ -98,17 +84,17 @@ static inline int template_callback_int32(unpack_user* u, int32_t d, msgpack_unp
9884 return 0 ;
9985}
10086
101- static inline int template_callback_int16 (unpack_user * u , int16_t d , msgpack_unpack_object * o )
87+ static inline int unpack_callback_int16 (unpack_user * u , int16_t d , msgpack_unpack_object * o )
10288{
103- return template_callback_int32 (u , d , o );
89+ return unpack_callback_int32 (u , d , o );
10490}
10591
106- static inline int template_callback_int8 (unpack_user * u , int8_t d , msgpack_unpack_object * o )
92+ static inline int unpack_callback_int8 (unpack_user * u , int8_t d , msgpack_unpack_object * o )
10793{
108- return template_callback_int32 (u , d , o );
94+ return unpack_callback_int32 (u , d , o );
10995}
11096
111- static inline int template_callback_int64 (unpack_user * u , int64_t d , msgpack_unpack_object * o )
97+ static inline int unpack_callback_int64 (unpack_user * u , int64_t d , msgpack_unpack_object * o )
11298{
11399 PyObject * p = PyLong_FromLongLong (d );
114100 if (!p )
@@ -117,7 +103,7 @@ static inline int template_callback_int64(unpack_user* u, int64_t d, msgpack_unp
117103 return 0 ;
118104}
119105
120- static inline int template_callback_double (unpack_user * u , double d , msgpack_unpack_object * o )
106+ static inline int unpack_callback_double (unpack_user * u , double d , msgpack_unpack_object * o )
121107{
122108 PyObject * p = PyFloat_FromDouble (d );
123109 if (!p )
@@ -126,21 +112,21 @@ static inline int template_callback_double(unpack_user* u, double d, msgpack_unp
126112 return 0 ;
127113}
128114
129- static inline int template_callback_float (unpack_user * u , float d , msgpack_unpack_object * o )
115+ static inline int unpack_callback_float (unpack_user * u , float d , msgpack_unpack_object * o )
130116{
131- return template_callback_double (u , d , o );
117+ return unpack_callback_double (u , d , o );
132118}
133119
134- static inline int template_callback_nil (unpack_user * u , msgpack_unpack_object * o )
120+ static inline int unpack_callback_nil (unpack_user * u , msgpack_unpack_object * o )
135121{ Py_INCREF (Py_None ); * o = Py_None ; return 0 ; }
136122
137- static inline int template_callback_true (unpack_user * u , msgpack_unpack_object * o )
123+ static inline int unpack_callback_true (unpack_user * u , msgpack_unpack_object * o )
138124{ Py_INCREF (Py_True ); * o = Py_True ; return 0 ; }
139125
140- static inline int template_callback_false (unpack_user * u , msgpack_unpack_object * o )
126+ static inline int unpack_callback_false (unpack_user * u , msgpack_unpack_object * o )
141127{ Py_INCREF (Py_False ); * o = Py_False ; return 0 ; }
142128
143- static inline int template_callback_array (unpack_user * u , unsigned int n , msgpack_unpack_object * o )
129+ static inline int unpack_callback_array (unpack_user * u , unsigned int n , msgpack_unpack_object * o )
144130{
145131 PyObject * p = u -> use_list ? PyList_New (n ) : PyTuple_New (n );
146132
@@ -150,7 +136,7 @@ static inline int template_callback_array(unpack_user* u, unsigned int n, msgpac
150136 return 0 ;
151137}
152138
153- static inline int template_callback_array_item (unpack_user * u , unsigned int current , msgpack_unpack_object * c , msgpack_unpack_object o )
139+ static inline int unpack_callback_array_item (unpack_user * u , unsigned int current , msgpack_unpack_object * c , msgpack_unpack_object o )
154140{
155141 if (u -> use_list )
156142 PyList_SET_ITEM (* c , current , o );
@@ -159,7 +145,7 @@ static inline int template_callback_array_item(unpack_user* u, unsigned int curr
159145 return 0 ;
160146}
161147
162- static inline int template_callback_array_end (unpack_user * u , msgpack_unpack_object * c )
148+ static inline int unpack_callback_array_end (unpack_user * u , msgpack_unpack_object * c )
163149{
164150 if (u -> list_hook ) {
165151 PyObject * new_c = PyEval_CallFunction (u -> list_hook , "(O)" , * c );
@@ -171,7 +157,7 @@ static inline int template_callback_array_end(unpack_user* u, msgpack_unpack_obj
171157 return 0 ;
172158}
173159
174- static inline int template_callback_map (unpack_user * u , unsigned int n , msgpack_unpack_object * o )
160+ static inline int unpack_callback_map (unpack_user * u , unsigned int n , msgpack_unpack_object * o )
175161{
176162 PyObject * p ;
177163 if (u -> has_pairs_hook ) {
@@ -186,7 +172,7 @@ static inline int template_callback_map(unpack_user* u, unsigned int n, msgpack_
186172 return 0 ;
187173}
188174
189- static inline int template_callback_map_item (unpack_user * u , unsigned int current , msgpack_unpack_object * c , msgpack_unpack_object k , msgpack_unpack_object v )
175+ static inline int unpack_callback_map_item (unpack_user * u , unsigned int current , msgpack_unpack_object * c , msgpack_unpack_object k , msgpack_unpack_object v )
190176{
191177 if (u -> has_pairs_hook ) {
192178 msgpack_unpack_object item = PyTuple_Pack (2 , k , v );
@@ -205,7 +191,7 @@ static inline int template_callback_map_item(unpack_user* u, unsigned int curren
205191 return -1 ;
206192}
207193
208- static inline int template_callback_map_end (unpack_user * u , msgpack_unpack_object * c )
194+ static inline int unpack_callback_map_end (unpack_user * u , msgpack_unpack_object * c )
209195{
210196 if (u -> object_hook ) {
211197 PyObject * new_c = PyEval_CallFunction (u -> object_hook , "(O)" , * c );
@@ -218,7 +204,7 @@ static inline int template_callback_map_end(unpack_user* u, msgpack_unpack_objec
218204 return 0 ;
219205}
220206
221- static inline int template_callback_raw (unpack_user * u , const char * b , const char * p , unsigned int l , msgpack_unpack_object * o )
207+ static inline int unpack_callback_raw (unpack_user * u , const char * b , const char * p , unsigned int l , msgpack_unpack_object * o )
222208{
223209 PyObject * py ;
224210 if (u -> encoding ) {
0 commit comments