Skip to content

Commit 2e9c01a

Browse files
committed
lift that msgpack template naming madness
1 parent 7a853f9 commit 2e9c01a

File tree

4 files changed

+73
-126
lines changed

4 files changed

+73
-126
lines changed

msgpack.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -159,13 +159,13 @@ PS_SERIALIZER_DECODE_FUNC(msgpack) /* {{{ */ {
159159
msgpack_unpack_t mp;
160160
size_t off = 0;
161161

162-
template_init(&mp);
162+
msgpack_unserialize_init(&mp);
163163

164164
ZVAL_UNDEF(&tmp);
165165
mp.user.retval = &tmp;
166166
mp.user.eof = val + vallen;
167167

168-
ret = template_execute(&mp, val, vallen, &off);
168+
ret = msgpack_unserialize_execute(&mp, val, vallen, &off);
169169
if (Z_TYPE_P(mp.user.retval) == IS_REFERENCE) {
170170
ZVAL_DEREF(mp.user.retval);
171171
}
@@ -216,12 +216,12 @@ PHP_MSGPACK_API int php_msgpack_unserialize(zval *return_value, char *str, size_
216216
return FAILURE;
217217
}
218218

219-
template_init(&mp);
219+
msgpack_unserialize_init(&mp);
220220

221221
mp.user.retval = return_value;
222222
mp.user.eof = str + str_len;
223223

224-
ret = template_execute(&mp, str, (size_t)str_len, &off);
224+
ret = msgpack_unserialize_execute(&mp, str, (size_t)str_len, &off);
225225

226226
switch (ret) {
227227
case MSGPACK_UNPACK_NOMEM_ERROR:

msgpack_class.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ static ZEND_METHOD(msgpack_unpacker, __construct) /* {{{ */ {
297297
unpacker->finished = 0;
298298
unpacker->error = 0;
299299

300-
template_init(&unpacker->mp);
300+
msgpack_unserialize_init(&unpacker->mp);
301301
}
302302
/* }}} */
303303

@@ -385,15 +385,15 @@ static ZEND_METHOD(msgpack_unpacker, execute) /* {{{ */ {
385385
msgpack_unserialize_var_destroy(&unpacker->mp.user.var_hash, unpacker->error);
386386
unpacker->error = 0;
387387

388-
template_init(&unpacker->mp);
388+
msgpack_unserialize_init(&unpacker->mp);
389389
}
390390
(&unpacker->mp)->user.retval = &unpacker->retval;
391391
(&unpacker->mp)->user.eof = data + len;
392392

393393
MSGPACK_G(error_display) = 0;
394394
MSGPACK_G(php_only) = unpacker->php_only;
395395

396-
ret = template_execute(&unpacker->mp, data, len, &off);
396+
ret = msgpack_unserialize_execute(&unpacker->mp, data, len, &off);
397397

398398
MSGPACK_G(error_display) = error_display;
399399
MSGPACK_G(php_only) = php_only;
@@ -474,7 +474,7 @@ static ZEND_METHOD(msgpack_unpacker, reset) /* {{{ */ {
474474
msgpack_unserialize_var_destroy(&unpacker->mp.user.var_hash, unpacker->error);
475475
unpacker->error = 0;
476476

477-
template_init(&unpacker->mp);
477+
msgpack_unserialize_init(&unpacker->mp);
478478
}
479479
/* }}} */
480480

msgpack_unpack.c

+26-33
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ typedef struct var_entries {
7272
return MSGPACK_UNPACK_PARSE_ERROR; \
7373
}
7474

75-
static zval *msgpack_var_push(msgpack_unserialize_data_t *var_hashx) /* {{{ */ {
75+
static zval *msgpack_var_push(msgpack_var_hash *var_hashx) /* {{{ */ {
7676
var_entries *var_hash, *prev = NULL;
7777

7878
if (!var_hashx) {
@@ -110,7 +110,7 @@ static inline void msgpack_var_replace(zval *old, zval *new) /* {{{ */ {
110110
}
111111
/* }}} */
112112

113-
static zval *msgpack_var_access(msgpack_unserialize_data_t *var_hashx, zend_long id) /* {{{ */ {
113+
static zval *msgpack_var_access(msgpack_var_hash *var_hashx, zend_long id) /* {{{ */ {
114114
var_entries *var_hash = var_hashx->first;
115115

116116
while (id > VAR_ENTRIES_MAX && var_hash && var_hash->used_slots == VAR_ENTRIES_MAX) {
@@ -134,7 +134,7 @@ static zval *msgpack_var_access(msgpack_unserialize_data_t *var_hashx, zend_long
134134
}
135135
/* }}} */
136136

137-
static zval *msgpack_stack_push(msgpack_unserialize_data_t *var_hashx) /* {{{ */ {
137+
static zval *msgpack_stack_push(msgpack_var_hash *var_hashx) /* {{{ */ {
138138
var_entries *var_hash, *prev = NULL;
139139

140140
if (!var_hashx) {
@@ -165,7 +165,7 @@ static zval *msgpack_stack_push(msgpack_unserialize_data_t *var_hashx) /* {{{ */
165165
}
166166
/* }}} */
167167

168-
static void msgpack_stack_pop(msgpack_unserialize_data_t *var_hashx, zval *v) /* {{{ */ {
168+
static void msgpack_stack_pop(msgpack_var_hash *var_hashx, zval *v) /* {{{ */ {
169169
var_entries *var_hash = var_hashx->last_dtor;
170170

171171
while (var_hash && var_hash->used_slots == VAR_ENTRIES_MAX) {
@@ -343,13 +343,13 @@ static zend_class_entry* msgpack_unserialize_class(zval **container, zend_string
343343
}
344344
/* }}} */
345345

346-
void msgpack_unserialize_var_init(msgpack_unserialize_data_t *var_hashx) /* {{{ */ {
346+
void msgpack_unserialize_var_init(msgpack_var_hash *var_hashx) /* {{{ */ {
347347
var_hashx->first = var_hashx->last = NULL;
348348
var_hashx->first_dtor = var_hashx->last_dtor = NULL;
349349
}
350350
/* }}} */
351351

352-
void msgpack_unserialize_var_destroy(msgpack_unserialize_data_t *var_hashx, zend_bool err) /* {{{ */ {
352+
void msgpack_unserialize_var_destroy(msgpack_var_hash *var_hashx, zend_bool err) /* {{{ */ {
353353
zend_long i;
354354
void *next;
355355
var_entries *var_hash = var_hashx->first;
@@ -377,14 +377,7 @@ void msgpack_unserialize_var_destroy(msgpack_unserialize_data_t *var_hashx, zend
377377
}
378378
/* }}} */
379379

380-
void msgpack_unserialize_init(msgpack_unserialize_data *unpack) /* {{{ */ {
381-
unpack->deps = 0;
382-
unpack->type = MSGPACK_SERIALIZE_TYPE_NONE;
383-
msgpack_unserialize_var_init(&unpack->var_hash);
384-
}
385-
/* }}} */
386-
387-
int msgpack_unserialize_uint8(msgpack_unserialize_data *unpack, uint8_t data, zval **obj) /* {{{ */ {
380+
int msgpack_unserialize_uint8(msgpack_unpack_data *unpack, uint8_t data, zval **obj) /* {{{ */ {
388381
MSGPACK_UNSERIALIZE_ALLOC_STACK(unpack);
389382

390383
ZVAL_LONG(*obj, data);
@@ -393,7 +386,7 @@ int msgpack_unserialize_uint8(msgpack_unserialize_data *unpack, uint8_t data, zv
393386
}
394387
/* }}} */
395388

396-
int msgpack_unserialize_uint16(msgpack_unserialize_data *unpack, uint16_t data, zval **obj) /* {{{ */ {
389+
int msgpack_unserialize_uint16(msgpack_unpack_data *unpack, uint16_t data, zval **obj) /* {{{ */ {
397390
MSGPACK_UNSERIALIZE_ALLOC_STACK(unpack);
398391

399392
ZVAL_LONG(*obj, data);
@@ -402,7 +395,7 @@ int msgpack_unserialize_uint16(msgpack_unserialize_data *unpack, uint16_t data,
402395
}
403396
/* }}} */
404397

405-
int msgpack_unserialize_uint32(msgpack_unserialize_data *unpack, uint32_t data, zval **obj) /* {{{ */ {
398+
int msgpack_unserialize_uint32(msgpack_unpack_data *unpack, uint32_t data, zval **obj) /* {{{ */ {
406399
MSGPACK_UNSERIALIZE_ALLOC_STACK(unpack);
407400

408401
if (data <= (uint32_t) ZEND_LONG_MAX) {
@@ -425,7 +418,7 @@ static inline char *print_u64_to_buf(char *buf, uint64_t num) {
425418
return buf;
426419
}
427420

428-
int msgpack_unserialize_uint64(msgpack_unserialize_data *unpack, uint64_t data, zval **obj) /* {{{ */ {
421+
int msgpack_unserialize_uint64(msgpack_unpack_data *unpack, uint64_t data, zval **obj) /* {{{ */ {
429422
MSGPACK_UNSERIALIZE_ALLOC_STACK(unpack);
430423

431424
if (data <= (uint64_t) ZEND_LONG_MAX) {
@@ -441,7 +434,7 @@ int msgpack_unserialize_uint64(msgpack_unserialize_data *unpack, uint64_t data,
441434
}
442435
/* }}} */
443436

444-
int msgpack_unserialize_int8(msgpack_unserialize_data *unpack, int8_t data, zval **obj) /* {{{ */ {
437+
int msgpack_unserialize_int8(msgpack_unpack_data *unpack, int8_t data, zval **obj) /* {{{ */ {
445438
MSGPACK_UNSERIALIZE_ALLOC_STACK(unpack);
446439

447440
ZVAL_LONG(*obj, data);
@@ -450,7 +443,7 @@ int msgpack_unserialize_int8(msgpack_unserialize_data *unpack, int8_t data, zval
450443
}
451444
/* }}} */
452445

453-
int msgpack_unserialize_int16(msgpack_unserialize_data *unpack, int16_t data, zval **obj) /* {{{ */ {
446+
int msgpack_unserialize_int16(msgpack_unpack_data *unpack, int16_t data, zval **obj) /* {{{ */ {
454447
MSGPACK_UNSERIALIZE_ALLOC_STACK(unpack);
455448

456449
ZVAL_LONG(*obj, data);
@@ -459,7 +452,7 @@ int msgpack_unserialize_int16(msgpack_unserialize_data *unpack, int16_t data, zv
459452
}
460453
/* }}} */
461454

462-
int msgpack_unserialize_int32(msgpack_unserialize_data *unpack, int32_t data, zval **obj) /* {{{ */ {
455+
int msgpack_unserialize_int32(msgpack_unpack_data *unpack, int32_t data, zval **obj) /* {{{ */ {
463456
MSGPACK_UNSERIALIZE_ALLOC_STACK(unpack);
464457

465458
ZVAL_LONG(*obj, data);
@@ -468,7 +461,7 @@ int msgpack_unserialize_int32(msgpack_unserialize_data *unpack, int32_t data, zv
468461
}
469462
/* }}} */
470463

471-
int msgpack_unserialize_int64(msgpack_unserialize_data *unpack, int64_t data, zval **obj) /* {{{ */ {
464+
int msgpack_unserialize_int64(msgpack_unpack_data *unpack, int64_t data, zval **obj) /* {{{ */ {
472465
MSGPACK_UNSERIALIZE_ALLOC_STACK(unpack);
473466

474467
ZVAL_LONG(*obj, data);
@@ -477,7 +470,7 @@ int msgpack_unserialize_int64(msgpack_unserialize_data *unpack, int64_t data, zv
477470
}
478471
/* }}} */
479472

480-
int msgpack_unserialize_float(msgpack_unserialize_data *unpack, float data, zval **obj) /* {{{ */ {
473+
int msgpack_unserialize_float(msgpack_unpack_data *unpack, float data, zval **obj) /* {{{ */ {
481474
MSGPACK_UNSERIALIZE_ALLOC_STACK(unpack);
482475

483476
ZVAL_DOUBLE(*obj, data);
@@ -486,7 +479,7 @@ int msgpack_unserialize_float(msgpack_unserialize_data *unpack, float data, zval
486479
}
487480
/* }}} */
488481

489-
int msgpack_unserialize_double(msgpack_unserialize_data *unpack, double data, zval **obj) /* {{{ */ {
482+
int msgpack_unserialize_double(msgpack_unpack_data *unpack, double data, zval **obj) /* {{{ */ {
490483
MSGPACK_UNSERIALIZE_ALLOC_STACK(unpack);
491484

492485
ZVAL_DOUBLE(*obj, data);
@@ -495,7 +488,7 @@ int msgpack_unserialize_double(msgpack_unserialize_data *unpack, double data, zv
495488
}
496489
/* }}} */
497490

498-
int msgpack_unserialize_nil(msgpack_unserialize_data *unpack, zval **obj) /* {{{ */ {
491+
int msgpack_unserialize_nil(msgpack_unpack_data *unpack, zval **obj) /* {{{ */ {
499492
MSGPACK_UNSERIALIZE_ALLOC_STACK(unpack);
500493

501494
ZVAL_NULL(*obj);
@@ -504,7 +497,7 @@ int msgpack_unserialize_nil(msgpack_unserialize_data *unpack, zval **obj) /* {{{
504497
}
505498
/* }}} */
506499

507-
int msgpack_unserialize_true(msgpack_unserialize_data *unpack, zval **obj) /* {{{ */ {
500+
int msgpack_unserialize_true(msgpack_unpack_data *unpack, zval **obj) /* {{{ */ {
508501
MSGPACK_UNSERIALIZE_ALLOC_STACK(unpack);
509502

510503
ZVAL_BOOL(*obj, 1);
@@ -513,7 +506,7 @@ int msgpack_unserialize_true(msgpack_unserialize_data *unpack, zval **obj) /* {{
513506
}
514507
/* }}} */
515508

516-
int msgpack_unserialize_false(msgpack_unserialize_data *unpack, zval **obj) /* {{{ */ {
509+
int msgpack_unserialize_false(msgpack_unpack_data *unpack, zval **obj) /* {{{ */ {
517510
MSGPACK_UNSERIALIZE_ALLOC_STACK(unpack);
518511

519512
ZVAL_BOOL(*obj, 0);
@@ -522,7 +515,7 @@ int msgpack_unserialize_false(msgpack_unserialize_data *unpack, zval **obj) /* {
522515
}
523516
/* }}} */
524517

525-
int msgpack_unserialize_str(msgpack_unserialize_data *unpack, const char* base, const char* data, unsigned int len, zval **obj) /* {{{ */ {
518+
int msgpack_unserialize_str(msgpack_unpack_data *unpack, const char* base, const char* data, unsigned int len, zval **obj) /* {{{ */ {
526519
MSGPACK_VALIDATE_INPUT(unpack, data, len);
527520
MSGPACK_UNSERIALIZE_ALLOC_STACK(unpack);
528521

@@ -537,7 +530,7 @@ int msgpack_unserialize_str(msgpack_unserialize_data *unpack, const char* base,
537530
}
538531
/* }}} */
539532

540-
int msgpack_unserialize_ext(msgpack_unserialize_data *unpack, const char* base, const char* data, unsigned int len, zval **obj) /* {{{ */ {
533+
int msgpack_unserialize_ext(msgpack_unpack_data *unpack, const char* base, const char* data, unsigned int len, zval **obj) /* {{{ */ {
541534
MSGPACK_VALIDATE_INPUT(unpack, data, len);
542535
MSGPACK_UNSERIALIZE_ALLOC_STACK(unpack);
543536

@@ -547,7 +540,7 @@ int msgpack_unserialize_ext(msgpack_unserialize_data *unpack, const char* base,
547540
}
548541
/* }}} */
549542

550-
int msgpack_unserialize_array(msgpack_unserialize_data *unpack, unsigned int count, zval **obj) /* {{{ */ {
543+
int msgpack_unserialize_array(msgpack_unpack_data *unpack, unsigned int count, zval **obj) /* {{{ */ {
551544
MSGPACK_UNSERIALIZE_ALLOC_VALUE(unpack);
552545

553546
array_init_size(*obj, MIN(count, 1<<16));
@@ -560,7 +553,7 @@ int msgpack_unserialize_array(msgpack_unserialize_data *unpack, unsigned int cou
560553
}
561554
/* }}} */
562555

563-
int msgpack_unserialize_array_item(msgpack_unserialize_data *unpack, zval **container, zval *obj) /* {{{ */ {
556+
int msgpack_unserialize_array_item(msgpack_unpack_data *unpack, zval **container, zval *obj) /* {{{ */ {
564557
zval *nval;
565558

566559
if (!*container || Z_TYPE_P(*container) != IS_ARRAY) {
@@ -580,7 +573,7 @@ int msgpack_unserialize_array_item(msgpack_unserialize_data *unpack, zval **cont
580573
}
581574
/* }}} */
582575

583-
int msgpack_unserialize_map(msgpack_unserialize_data *unpack, unsigned int count, zval **obj) /* {{{ */ {
576+
int msgpack_unserialize_map(msgpack_unpack_data *unpack, unsigned int count, zval **obj) /* {{{ */ {
584577
MSGPACK_UNSERIALIZE_ALLOC_VALUE(unpack);
585578

586579
if (count) {
@@ -604,7 +597,7 @@ int msgpack_unserialize_map(msgpack_unserialize_data *unpack, unsigned int count
604597
}
605598
/* }}} */
606599

607-
int msgpack_unserialize_map_item(msgpack_unserialize_data *unpack, zval **container, zval *key, zval *val) /* {{{ */ {
600+
int msgpack_unserialize_map_item(msgpack_unpack_data *unpack, zval **container, zval *key, zval *val) /* {{{ */ {
608601
long deps;
609602
zval *nval;
610603
zval *container_val;
@@ -651,7 +644,7 @@ int msgpack_unserialize_map_item(msgpack_unserialize_data *unpack, zval **contai
651644
} else {
652645
int type = unpack->type;
653646
unpack->type = MSGPACK_SERIALIZE_TYPE_NONE;
654-
647+
655648
switch (type) {
656649
case MSGPACK_SERIALIZE_TYPE_CUSTOM_OBJECT:
657650
{

0 commit comments

Comments
 (0)