-
Notifications
You must be signed in to change notification settings - Fork 1
/
varien_object.c
4179 lines (3637 loc) · 117 KB
/
varien_object.c
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include "php.h"
#include "zend_interfaces.h"
#include "zend_exceptions.h"
#include "ext/standard/php_smart_str.h"
#include "ext/standard/php_string.h"
#include "varien_object.h"
#include <stdio.h>
#define INTERNAL_ARR_DEF -97623086 /* Default value for array properties, so we know when it was redeclared in subclass */
/* ---Protected property declarations-------*/
/* Dynamically calculated internal name of property and its hash */
typedef struct {
char *name;
int name_len;
ulong hash;
} vo_property_info_t;
/* Declaration of properties */
typedef struct {
char *name;
uint name_len;
zend_uchar type;
int flags;
long default_value;
vo_property_info_t *internal_info;
} vo_property_declaration_entry_t;
/* Macros for property declarations */
#define VO_DECLARE_PROP_ARRAY(property_name, flags, num_buckets_initially) {#property_name, sizeof(#property_name) - 1, IS_ARRAY, flags, num_buckets_initially, NULL}
#define VO_DECLARE_PROP_BOOL(property_name, flags, value) {#property_name, sizeof(#property_name) - 1, IS_BOOL, flags, value, NULL}
#define VO_DECLARE_PROP_NULL(property_name, flags) {#property_name, sizeof(#property_name) - 1, IS_NULL, flags, 0, NULL}
#define VO_DECLARE_PROP_END {NULL, 0, 0, 0, 0, NULL}
/* Property declaration */
static vo_property_declaration_entry_t vo_property_declarations[] = {
VO_DECLARE_PROP_ARRAY(_data, ZEND_ACC_PROTECTED, 16),
VO_DECLARE_PROP_BOOL(_hasDataChanges, ZEND_ACC_PROTECTED, FALSE),
VO_DECLARE_PROP_NULL(_origData, ZEND_ACC_PROTECTED),
VO_DECLARE_PROP_NULL(_idFieldName, ZEND_ACC_PROTECTED),
VO_DECLARE_PROP_ARRAY(_underscoreCache, ZEND_ACC_PROTECTED | ZEND_ACC_STATIC, 0),
VO_DECLARE_PROP_BOOL(_isDeleted, ZEND_ACC_PROTECTED, FALSE),
VO_DECLARE_PROP_ARRAY(_oldFieldsMap, ZEND_ACC_PROTECTED, 0),
VO_DECLARE_PROP_ARRAY(_syncFieldsMap, ZEND_ACC_PROTECTED, 0),
VO_DECLARE_PROP_NULL(_dirty, ZEND_ACC_PROTECTED),
VO_DECLARE_PROP_END
};
/*---Methods declaration---*/
PHP_METHOD(Varien_Object, __construct);
PHP_METHOD(Varien_Object, _initOldFieldsMap);
PHP_METHOD(Varien_Object, _prepareSyncFieldsMap);
PHP_METHOD(Varien_Object, _addFullNames);
PHP_METHOD(Varien_Object, _construct);
PHP_METHOD(Varien_Object, getData);
PHP_METHOD(Varien_Object, setData);
PHP_METHOD(Varien_Object, hasDataChanges);
PHP_METHOD(Varien_Object, isDeleted);
PHP_METHOD(Varien_Object, setIdFieldName);
PHP_METHOD(Varien_Object, getIdFieldName);
PHP_METHOD(Varien_Object, getId);
PHP_METHOD(Varien_Object, setId);
PHP_METHOD(Varien_Object, addData);
PHP_METHOD(Varien_Object, unsetData);
PHP_METHOD(Varien_Object, unsetOldData);
PHP_METHOD(Varien_Object, _getData);
PHP_METHOD(Varien_Object, setDataUsingMethod);
PHP_METHOD(Varien_Object, getDataUsingMethod);
PHP_METHOD(Varien_Object, getDataSetDefault);
PHP_METHOD(Varien_Object, hasData);
PHP_METHOD(Varien_Object, __toArray);
PHP_METHOD(Varien_Object, toArray);
PHP_METHOD(Varien_Object, _prepareArray);
PHP_METHOD(Varien_Object, __toXml);
PHP_METHOD(Varien_Object, toXml);
PHP_METHOD(Varien_Object, __toJson);
PHP_METHOD(Varien_Object, toJson);
PHP_METHOD(Varien_Object, toString);
PHP_METHOD(Varien_Object, __call);
PHP_METHOD(Varien_Object, __get);
PHP_METHOD(Varien_Object, __set);
PHP_METHOD(Varien_Object, isEmpty);
PHP_METHOD(Varien_Object, _underscore);
PHP_METHOD(Varien_Object, _camelize);
PHP_METHOD(Varien_Object, serialize);
PHP_METHOD(Varien_Object, getOrigData);
PHP_METHOD(Varien_Object, setOrigData);
PHP_METHOD(Varien_Object, dataHasChangedFor);
PHP_METHOD(Varien_Object, setDataChanges);
PHP_METHOD(Varien_Object, debug);
PHP_METHOD(Varien_Object, offsetSet);
PHP_METHOD(Varien_Object, offsetExists);
PHP_METHOD(Varien_Object, offsetUnset);
PHP_METHOD(Varien_Object, offsetGet);
PHP_METHOD(Varien_Object, isDirty);
PHP_METHOD(Varien_Object, flagDirty);
ZEND_BEGIN_ARG_INFO_EX(vo_getData_arg_info, 0, 0, 0)
ZEND_ARG_INFO(0, key)
ZEND_ARG_INFO(0, index)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(vo_setData_arg_info, 0, 0, 1)
ZEND_ARG_INFO(0, key)
ZEND_ARG_INFO(0, value)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(vo_isDeleted_arg_info, 0, 0, 0)
ZEND_ARG_INFO(0, isDeleted)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(vo_setIdFieldName_arg_info, 0, 0, 1)
ZEND_ARG_INFO(0, name)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(vo_setId_arg_info, 0, 0, 1)
ZEND_ARG_INFO(0, value)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(vo_addData_arg_info, 0, 0, 1)
ZEND_ARG_ARRAY_INFO(0, arr, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(vo_unsetData_arg_info, 0, 0, 0)
ZEND_ARG_INFO(0, key)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(vo_unsetOldData_arg_info, 0, 0, 0)
ZEND_ARG_INFO(0, key)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(vo__getData_arg_info, 0, 0, 1)
ZEND_ARG_INFO(0, key)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(vo_setDataUsingMethod_arg_info, 0, 0, 1)
ZEND_ARG_INFO(0, key)
ZEND_ARG_INFO(0, args)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(vo_getDataUsingMethod_arg_info, 0, 0, 1)
ZEND_ARG_INFO(0, key)
ZEND_ARG_INFO(0, args)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(vo_getDataSetDefault_arg_info, 0, 0, 2)
ZEND_ARG_INFO(0, key)
ZEND_ARG_INFO(0, default)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(vo_hasData_arg_info, 0, 0, 0)
ZEND_ARG_INFO(0, key)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(vo_toArray_arg_info, 0, 0, 0)
ZEND_ARG_ARRAY_INFO(0, arrAttributes, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(vo__prepareArray_arg_info, 0, 0, 1)
ZEND_ARG_INFO(1, arr)
ZEND_ARG_ARRAY_INFO(0, elements, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(vo_toXml_arg_info, 0, 0, 0)
ZEND_ARG_ARRAY_INFO(0, arrAttributes, 0)
ZEND_ARG_INFO(0, rootName)
ZEND_ARG_INFO(0, addOpenTag)
ZEND_ARG_INFO(0, addCdata)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(vo_toJson_arg_info, 0, 0, 0)
ZEND_ARG_ARRAY_INFO(0, arrAttributes, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(vo_toString_arg_info, 0, 0, 0)
ZEND_ARG_INFO(0, format)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(vo___call_arg_info, 0, 0, 2)
ZEND_ARG_INFO(0, method)
ZEND_ARG_INFO(0, args)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(vo___get_arg_info, 0, 0, 1)
ZEND_ARG_INFO(0, var)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(vo___set_arg_info, 0, 0, 2)
ZEND_ARG_INFO(0, var)
ZEND_ARG_INFO(0, value)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(vo__underscore_arg_info, 0, 0, 1)
ZEND_ARG_INFO(0, name)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(vo__camelize_arg_info, 0, 0, 1)
ZEND_ARG_INFO(0, name)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(vo_serialize_arg_info, 0, 0, 0)
ZEND_ARG_INFO(0, attributes)
ZEND_ARG_INFO(0, valueSeparator)
ZEND_ARG_INFO(0, fieldSeparator)
ZEND_ARG_INFO(0, quote)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(vo_getOrigData_arg_info, 0, 0, 0)
ZEND_ARG_INFO(0, key)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(vo_setOrigData_arg_info, 0, 0, 0)
ZEND_ARG_INFO(0, key)
ZEND_ARG_INFO(0, data)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(vo_dataHasChangedFor_arg_info, 0, 0, 1)
ZEND_ARG_INFO(0, field)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(vo_setDataChanges_arg_info, 0, 0, 1)
ZEND_ARG_INFO(0, value)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(vo_debug_arg_info, 0, 0, 0)
ZEND_ARG_INFO(0, data)
ZEND_ARG_INFO(0, objects)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(vo_offsetSet_arg_info, 0, 0, 2)
ZEND_ARG_INFO(0, offset)
ZEND_ARG_INFO(0, value)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(vo_offsetExists_arg_info, 0, 0, 1)
ZEND_ARG_INFO(0, offset)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(vo_offsetUnset_arg_info, 0, 0, 1)
ZEND_ARG_INFO(0, offset)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(vo_offsetGet_arg_info, 0, 0, 1)
ZEND_ARG_INFO(0, offset)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(vo_isDirty_arg_info, 0, 0, 0)
ZEND_ARG_INFO(0, field)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(vo_flagDirty_arg_info, 0, 0, 1)
ZEND_ARG_INFO(0, field)
ZEND_ARG_INFO(0, flag)
ZEND_END_ARG_INFO()
static const zend_function_entry vo_methods[] = {
PHP_ME(Varien_Object, __construct, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_CTOR)
PHP_ME(Varien_Object, _initOldFieldsMap, NULL, ZEND_ACC_PROTECTED)
PHP_ME(Varien_Object, _prepareSyncFieldsMap, NULL, ZEND_ACC_PROTECTED)
PHP_ME(Varien_Object, _addFullNames, NULL, ZEND_ACC_PROTECTED)
PHP_ME(Varien_Object, _construct, NULL, ZEND_ACC_PROTECTED)
PHP_ME(Varien_Object, getData, vo_getData_arg_info, ZEND_ACC_PUBLIC)
PHP_ME(Varien_Object, setData, vo_setData_arg_info, ZEND_ACC_PUBLIC)
PHP_ME(Varien_Object, hasDataChanges, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Varien_Object, isDeleted, vo_isDeleted_arg_info, ZEND_ACC_PUBLIC)
PHP_ME(Varien_Object, setIdFieldName, vo_setIdFieldName_arg_info, ZEND_ACC_PUBLIC)
PHP_ME(Varien_Object, getIdFieldName, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Varien_Object, getId, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Varien_Object, setId, vo_setId_arg_info, ZEND_ACC_PUBLIC)
PHP_ME(Varien_Object, addData, vo_addData_arg_info, ZEND_ACC_PUBLIC)
PHP_ME(Varien_Object, unsetData, vo_unsetData_arg_info, ZEND_ACC_PUBLIC)
PHP_ME(Varien_Object, unsetOldData, vo_unsetOldData_arg_info, ZEND_ACC_PUBLIC)
PHP_ME(Varien_Object, _getData, NULL, ZEND_ACC_PROTECTED)
PHP_ME(Varien_Object, setDataUsingMethod, vo_setDataUsingMethod_arg_info, ZEND_ACC_PUBLIC)
PHP_ME(Varien_Object, getDataUsingMethod, vo_getDataUsingMethod_arg_info, ZEND_ACC_PUBLIC)
PHP_ME(Varien_Object, getDataSetDefault, vo_getDataSetDefault_arg_info, ZEND_ACC_PUBLIC)
PHP_ME(Varien_Object, hasData, vo_hasData_arg_info, ZEND_ACC_PUBLIC)
PHP_ME(Varien_Object, __toArray, vo_toArray_arg_info, ZEND_ACC_PUBLIC)
PHP_ME(Varien_Object, toArray, vo_toArray_arg_info, ZEND_ACC_PUBLIC)
PHP_ME(Varien_Object, _prepareArray, vo__prepareArray_arg_info, ZEND_ACC_PROTECTED)
PHP_ME(Varien_Object, __toXml, vo_toXml_arg_info, ZEND_ACC_PROTECTED)
PHP_ME(Varien_Object, toXml, vo_toXml_arg_info, ZEND_ACC_PUBLIC)
PHP_ME(Varien_Object, __toJson, vo_toJson_arg_info, ZEND_ACC_PROTECTED)
PHP_ME(Varien_Object, toJson, vo_toJson_arg_info, ZEND_ACC_PUBLIC)
PHP_ME(Varien_Object, toString, vo_toString_arg_info, ZEND_ACC_PUBLIC)
PHP_ME(Varien_Object, __call, vo___call_arg_info, ZEND_ACC_PUBLIC)
PHP_ME(Varien_Object, __get, vo___get_arg_info, ZEND_ACC_PUBLIC)
PHP_ME(Varien_Object, __set, vo___set_arg_info, ZEND_ACC_PUBLIC)
PHP_ME(Varien_Object, isEmpty, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Varien_Object, _underscore, vo__underscore_arg_info, ZEND_ACC_PROTECTED)
PHP_ME(Varien_Object, _camelize, vo__camelize_arg_info, ZEND_ACC_PROTECTED)
PHP_ME(Varien_Object, serialize, vo_serialize_arg_info, ZEND_ACC_PUBLIC)
PHP_ME(Varien_Object, getOrigData, vo_getOrigData_arg_info, ZEND_ACC_PUBLIC)
PHP_ME(Varien_Object, setOrigData, vo_setOrigData_arg_info, ZEND_ACC_PUBLIC)
PHP_ME(Varien_Object, dataHasChangedFor, vo_dataHasChangedFor_arg_info, ZEND_ACC_PUBLIC)
PHP_ME(Varien_Object, setDataChanges, vo_setDataChanges_arg_info, ZEND_ACC_PUBLIC)
PHP_ME(Varien_Object, debug, vo_debug_arg_info, ZEND_ACC_PUBLIC)
PHP_ME(Varien_Object, offsetSet, vo_offsetSet_arg_info, ZEND_ACC_PUBLIC)
PHP_ME(Varien_Object, offsetExists, vo_offsetExists_arg_info, ZEND_ACC_PUBLIC)
PHP_ME(Varien_Object, offsetUnset, vo_offsetUnset_arg_info, ZEND_ACC_PUBLIC)
PHP_ME(Varien_Object, offsetGet, vo_offsetGet_arg_info, ZEND_ACC_PUBLIC)
PHP_ME(Varien_Object, isDirty, vo_isDirty_arg_info, ZEND_ACC_PUBLIC)
PHP_ME(Varien_Object, flagDirty, vo_flagDirty_arg_info, ZEND_ACC_PUBLIC)
PHP_FE_END
};
/*---Used variables---*/
static zend_class_entry *vo_class;
static int vo_def_props_num;
static vo_property_info_t *vo_data_property_info, *vo_isDeleted_property_info, *vo_idFieldName_property_info,
*vo_syncFieldsMap_property_info, *vo_oldFieldsMap_property_info, *vo_hasDataChanges_property_info,
*vo_origData_property_info, *vo_dirty_property_info;
/* Forward declarations */
static zend_object_value vo_create_handler(zend_class_entry *class_type TSRMLS_DC);
static void vo_create_default_array_properties(zend_object_value *obj_value TSRMLS_DC);
static void vo_create_default_array_static_properties(TSRMLS_DC);
static vo_property_info_t *get_protected_property_info(const char *name, int name_len, int persistent);
static zend_bool def_property_redeclared(const zval *obj_zval, const zend_class_entry *class_type, const vo_property_declaration_entry_t *property_declaration);
static int vo_callback_start_syncFieldsMap(zval **zv TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key);
static int vo_callback_make_syncFieldsMap(zval **zv TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key);
static void vo_convert_htmlentities(zval * value, char **result_str, uint *result_len);
/* Pseudo functions */
#define VO_EXTRACT_PROPERTY(property_name, obj_zval_p, property_zval_ppp) \
{ \
if (zend_hash_quick_find(Z_OBJPROP_P(obj_zval_p), vo##property_name##_property_info->name, vo##property_name##_property_info->name_len, vo##property_name##_property_info->hash, (void**)property_zval_ppp) == FAILURE) { \
/* Access to the property was changed, it cannot be found using cached hash. Fall back to standard mechanism of property fetching. */ \
zval *tmp_extracted_##property_name; \
tmp_extracted_##property_name = zend_read_property(Z_OBJCE_P(obj_zval_p), obj_zval_p, #property_name, sizeof(#property_name) - 1, FALSE TSRMLS_CC); \
*property_zval_ppp = &tmp_extracted_##property_name; \
} \
}
#define VO_VERIFY_SCALAR_INCOMING_VALUE_P(zv, name, action) \
if (zv) { \
zend_uchar verify_type; \
verify_type = Z_TYPE_P(zv); \
switch (verify_type) { \
case IS_NULL: \
case IS_LONG: \
case IS_DOUBLE: \
case IS_BOOL: \
case IS_STRING: \
case IS_CONSTANT: \
break; \
default: \
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Illegal value passed for " name); \
action; \
break; \
} \
}
/* Module initialization. Register Varien_Object class. */
int mage_varien_object_minit(TSRMLS_D)
{
zend_class_entry ce;
int i;
vo_property_declaration_entry_t *prop_declaration;
/*---Class---*/
INIT_CLASS_ENTRY(ce, "Varien_Object", vo_methods);
vo_class = zend_register_internal_class(&ce TSRMLS_CC);
zend_class_implements(vo_class TSRMLS_CC, 1, zend_ce_arrayaccess);
/*
Create custom "create object" handler, because internal class declarations cannot have arrays, objects or
resources as default properties. So we will assign arrays to properties in the custom handler.
*/
vo_class->create_object = vo_create_handler;
/*---Properties---*/
/* Note: array properties are initialized to arrays in create_handler */
for (i = 0; ; i++) {
prop_declaration = &vo_property_declarations[i];
if (!prop_declaration->name_len) {
break;
}
switch (prop_declaration->type) {
case IS_BOOL:
zend_declare_property_bool(vo_class, prop_declaration->name, prop_declaration->name_len, prop_declaration->default_value, prop_declaration->flags TSRMLS_CC);
break;
case IS_ARRAY:
/* There is no ability to declare default array property for internal class. And there is no ability to know, that
* a subclass has re-declared a property. Thus array properties are initially declared as special int values,
* but are reinitialized to empty arrays in the create_handler.
*/
zend_declare_property_long(vo_class, prop_declaration->name, prop_declaration->name_len, INTERNAL_ARR_DEF, prop_declaration->flags TSRMLS_CC);
break;
case IS_NULL:
zend_declare_property_null(vo_class, prop_declaration->name, prop_declaration->name_len, prop_declaration->flags TSRMLS_CC);
break;
default:
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Unknown property declaration type %s:%d", prop_declaration->name, prop_declaration->type);
break;
}
prop_declaration->internal_info = get_protected_property_info(prop_declaration->name, prop_declaration->name_len, TRUE);
};
/* Optimization - cache different values */
#if PHP_VERSION_ID < 50399
vo_def_props_num = zend_hash_num_elements(&vo_class->default_properties);
#else
vo_def_props_num = 16; // Will be resized anyway
#endif
vo_data_property_info = get_protected_property_info("_data", sizeof("_data") - 1, TRUE);
vo_isDeleted_property_info = get_protected_property_info("_isDeleted", sizeof("_isDeleted") - 1, TRUE);
vo_idFieldName_property_info = get_protected_property_info("_idFieldName", sizeof("_idFieldName") - 1, TRUE);
vo_syncFieldsMap_property_info = get_protected_property_info("_syncFieldsMap", sizeof("_syncFieldsMap") - 1, TRUE);
vo_oldFieldsMap_property_info = get_protected_property_info("_oldFieldsMap", sizeof("_oldFieldsMap") - 1, TRUE);
vo_hasDataChanges_property_info = get_protected_property_info("_hasDataChanges", sizeof("_hasDataChanges") - 1, TRUE);
vo_origData_property_info = get_protected_property_info("_origData", sizeof("_origData") - 1, TRUE);
vo_dirty_property_info = get_protected_property_info("_dirty", sizeof("_dirty") - 1, TRUE);
return SUCCESS;
}
/* Returns hash of a protected property, searching it in the array of properties */
static vo_property_info_t *get_protected_property_info(const char *name, int name_len, int persistent)
{
vo_property_info_t *result;
result = pemalloc(sizeof(vo_property_info_t), persistent);
zend_mangle_property_name(&result->name, &result->name_len, "*", 1, name, name_len, TRUE); /* Star (*) means protected property */
result->name_len++; /* Somehow additional \0 at the end also should be counted */
result->hash = zend_get_hash_value(result->name, result->name_len);
return result;
}
/* Custom handler, called on Varien_Object creation. Initializes default properties that must have array type. */
static zend_object_value vo_create_handler(zend_class_entry *class_type TSRMLS_DC)
{
zend_object *object;
zend_object_value retval;
zval *tmp;
/* Standard initialization */
retval = zend_objects_new(&object, class_type TSRMLS_CC);
zend_object_std_init(object, class_type TSRMLS_CC);
/* Copy class properties */
ALLOC_HASHTABLE(object->properties);
zend_hash_init(object->properties, vo_def_props_num, NULL, ZVAL_PTR_DTOR, FALSE);
#if PHP_VERSION_ID < 50399
zend_hash_copy(object->properties, &class_type->default_properties, zval_copy_property_ctor(class_type), (void *) &tmp, sizeof(zval *));
#else
object_properties_init(object, class_type);
#endif
/* Update properties that must be arrays by default */
vo_create_default_array_properties(&retval TSRMLS_CC);
return retval;
}
static inline void vo_create_default_array_properties(zend_object_value *obj_value TSRMLS_DC)
{
zval *obj_zval;
int i;
const vo_property_declaration_entry_t *prop_declaration;
zval *array_property;
HashTable *ht;
zend_class_entry *obj_ce;
MAKE_STD_ZVAL(obj_zval);
Z_TYPE_P(obj_zval) = IS_OBJECT;
Z_OBJVAL_P(obj_zval) = *obj_value;
obj_ce = Z_OBJCE_P(obj_zval);
for (i = 0; ; i++) {
prop_declaration = &vo_property_declarations[i];
if (!prop_declaration->name_len) {
break;
}
if (prop_declaration->type != IS_ARRAY) {
continue;
}
if (prop_declaration->flags & ZEND_ACC_STATIC) {
continue;
}
if (def_property_redeclared(obj_zval, obj_ce, prop_declaration)) {
continue;
}
ALLOC_HASHTABLE(ht);
if (zend_hash_init(ht, prop_declaration->default_value, NULL, ZVAL_PTR_DTOR, TRUE) == FAILURE) { /* Optimization - pre-allocate buffer for "default_value" buckets */
FREE_HASHTABLE(ht);
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Unable to init HashTable for object default property");
}
MAKE_STD_ZVAL(array_property);
Z_TYPE_P(array_property) = IS_ARRAY;
Z_ARRVAL_P(array_property) = ht;
zend_update_property(vo_class, obj_zval, prop_declaration->name, prop_declaration->name_len, array_property TSRMLS_CC);
zval_ptr_dtor(&array_property); /* It has been saved saved as object's property, so just decrease refcount */
}
FREE_ZVAL(obj_zval);
}
/* Request initialization. Create static members of Varien_Object class. */
int mage_varien_object_rinit(TSRMLS_D)
{
vo_create_default_array_static_properties(TSRMLS_C);
return SUCCESS;
}
static inline void vo_create_default_array_static_properties(TSRMLS_D)
{
int i;
const vo_property_declaration_entry_t *prop_declaration;
zval *array_property;
HashTable *ht;
for (i = 0; ; i++) {
prop_declaration = &vo_property_declarations[i];
if (!prop_declaration->name_len) {
break;
}
if (prop_declaration->type != IS_ARRAY) {
continue;
}
if (!(prop_declaration->flags & ZEND_ACC_STATIC)) {
continue;
}
ALLOC_HASHTABLE(ht);
if (zend_hash_init(ht, prop_declaration->default_value, NULL, ZVAL_PTR_DTOR, TRUE) == FAILURE) { /* Optimization - pre-allocate buffer for "default_value" buckets */
FREE_HASHTABLE(ht);
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Unable to init HashTable for object default property");
}
MAKE_STD_ZVAL(array_property);
Z_TYPE_P(array_property) = IS_ARRAY;
Z_ARRVAL_P(array_property) = ht;
zend_update_static_property(vo_class, prop_declaration->name, prop_declaration->name_len, array_property TSRMLS_CC);
zval_ptr_dtor(&array_property); /* It has been saved saved as class's property, so just decrease refcount */
}
}
static zend_bool def_property_redeclared(const zval *obj_zval, const zend_class_entry *class_type, const vo_property_declaration_entry_t *property_declaration) {
zval **def_property;
if (class_type == vo_class) {
return FALSE; /* This is our own class */
}
#if PHP_VERSION_ID < 50399
if (zend_hash_quick_find(&class_type->default_properties, property_declaration->internal_info->name, property_declaration->internal_info->name_len, property_declaration->internal_info->hash, (void **) &def_property) == FAILURE) {
#else
if (0) {
#endif
return TRUE; /* Internal name was changed, which means that protected access changed to public, which means property was redeclared */
}
if ((Z_TYPE_PP(def_property) == IS_LONG) && (Z_LVAL_PP(def_property) == INTERNAL_ARR_DEF)) {
return FALSE;
}
return TRUE;
}
/*
Extract variable value either as long or as string (conversion to string is done, if value is not int, bool or string).
If extracted as long, then val_str will be NULL.
If val_str must be disposed after usage, then dispose_str will be TRUE.
*/
static inline void expand_to_long_or_string_array_key(zval *z, long *val_long, char **val_str, uint *val_str_len, zend_bool *is_dispose_str TSRMLS_DC)
{
zval *tmp;
zend_uchar type = z ? Z_TYPE_P(z) : IS_NULL;
switch (type) {
case IS_LONG:
*val_long = Z_LVAL_P(z);
*val_str = NULL;
*is_dispose_str = FALSE;
break;
case IS_STRING:
*val_str = Z_STRVAL_P(z);
*val_str_len = Z_STRLEN_P(z);
*is_dispose_str = FALSE;
break;
case IS_BOOL:
*val_long = Z_BVAL_P(z) ? 1 : 0;
*val_str = NULL;
*is_dispose_str = FALSE;
break;
case IS_NULL:
*val_str = estrndup("", 1);
*val_str_len = 0;
*is_dispose_str = TRUE;
break;
default:
ALLOC_ZVAL(tmp);
MAKE_COPY_ZVAL(&z, tmp);
convert_to_string(tmp);
*val_str = Z_STRVAL_P(tmp);
*val_str_len = Z_STRLEN_P(tmp);
FREE_ZVAL(tmp);
*is_dispose_str = TRUE;
break;
}
}
/* public function __construct() */
PHP_METHOD(Varien_Object, __construct)
{
zval *obj_zval = getThis();
zval *param = NULL;
int num_args = ZEND_NUM_ARGS();
zend_class_entry *obj_ce = Z_OBJCE_P(obj_zval);
zval **oldFieldsMap;
/*
---PHP---
$this->_initOldFieldsMap();
*/
zend_call_method_with_0_params(&obj_zval, obj_ce, NULL, "_initoldfieldsmap", NULL);
/*
---PHP---
if ($this->_oldFieldsMap) {
$this->_prepareSyncFieldsMap();
}
*/
VO_EXTRACT_PROPERTY(_oldFieldsMap, obj_zval, &oldFieldsMap);
if (i_zend_is_true(*oldFieldsMap)) {
zend_call_method_with_0_params(&obj_zval, obj_ce, NULL, "_preparesyncfieldsmap", NULL);
}
/*
---PHP---
$args = func_get_args();
if (empty($args[0])) {
$args[0] = array();
}
$this->_data = $args[0];
*/
if (num_args) {
if (zend_parse_parameters(num_args TSRMLS_CC, "z!", ¶m) == SUCCESS) {
if (param) {
if (Z_TYPE_P(param) == IS_ARRAY) {
if (zend_hash_num_elements(Z_ARRVAL_P(param))) {
zend_update_property(obj_ce, obj_zval, "_data", sizeof("_data") - 1, param TSRMLS_CC);
}
} else {
php_error(E_WARNING, "Incoming parameter to Varien_Object::__construct() must be an array");
}
}
} else {
return;
}
}
/*
---PHP---
$this->_addFullNames();
*/
zend_call_method_with_0_params(&obj_zval, obj_ce, NULL, "_addfullnames", NULL);
/*
---PHP---
$this->_construct();
*/
zend_call_method_with_0_params(&obj_zval, obj_ce, NULL, "_construct", NULL);
}
/* protected function _initOldFieldsMap() */
PHP_METHOD(Varien_Object, _initOldFieldsMap)
{
}
/* protected function _prepareSyncFieldsMap() */
PHP_METHOD(Varien_Object, _prepareSyncFieldsMap)
{
zval *obj_zval = getThis();
zend_class_entry *obj_ce = Z_OBJCE_P(obj_zval);
zval **syncFieldsMap_pp, **oldFieldsMap_pp;
zval *syncFieldsMap, *oldFieldsMap;
int num_sync_elements;
HashTable *ht_for_property;
int next_long_index;
/*
---PHP---
$old2New = $this->_oldFieldsMap;
$new2Old = array_flip($this->_oldFieldsMap);
$this->_syncFieldsMap = array_merge($old2New, $new2Old);
*/
VO_EXTRACT_PROPERTY(_oldFieldsMap, obj_zval, &oldFieldsMap_pp);
oldFieldsMap = *oldFieldsMap_pp;
if (Z_TYPE_P(oldFieldsMap) != IS_ARRAY) {
php_error_docref(NULL TSRMLS_CC, E_ERROR, "_oldFieldsMap is not an array, while processing it through _prepareSyncFieldsMap() method");
}
/* Create new zval for syncFieldsMap */
num_sync_elements = zend_hash_num_elements(Z_ARRVAL_P(oldFieldsMap));
ALLOC_HASHTABLE(ht_for_property);
if (zend_hash_init(ht_for_property, num_sync_elements * 2, NULL, ZVAL_PTR_DTOR, FALSE) == FAILURE) {
FREE_HASHTABLE(ht_for_property);
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Unable to init HashTable for _syncFieldsMap");
}
VO_EXTRACT_PROPERTY(_syncFieldsMap, obj_zval, &syncFieldsMap_pp);
syncFieldsMap = *syncFieldsMap_pp;
if (!Z_ISREF_P(syncFieldsMap) && (Z_REFCOUNT_P(syncFieldsMap) > 1)) {
/* Create new zval and set it to object */
ALLOC_INIT_ZVAL(syncFieldsMap);
zend_update_property(obj_ce, obj_zval, "_syncFieldsMap", sizeof("_syncFieldsMap") - 1, syncFieldsMap TSRMLS_CC);
} else {
/* Keep current zval, just clean its current content */
zval_dtor(syncFieldsMap);
}
Z_TYPE_P(syncFieldsMap) = IS_ARRAY;
Z_ARRVAL_P(syncFieldsMap) = ht_for_property;
/* Copy values from oldFieldsMap, but change all int indexes to start from 0 */
next_long_index = 0;
zend_hash_apply_with_arguments(Z_ARRVAL_P(oldFieldsMap) TSRMLS_CC, (apply_func_args_t) vo_callback_start_syncFieldsMap, 1, ht_for_property, &next_long_index);
/* Add flipped pairs from oldFieldsMap, but int indexes must continue incrementing */
zend_hash_apply_with_arguments(Z_ARRVAL_P(oldFieldsMap) TSRMLS_CC, (apply_func_args_t) vo_callback_make_syncFieldsMap, 1, ht_for_property, &next_long_index);
/*
--PHP---
return $this;
*/
if (return_value_used) {
MAKE_COPY_ZVAL(&obj_zval, return_value);
}
}
/* Copy zvalue to the hash table, which is passed as additional argument */
static int vo_callback_start_syncFieldsMap(zval **zv TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key)
{
HashTable *target = va_arg(args, HashTable*);
int *next_long_index_p = va_arg(args, int*);
Z_ADDREF_PP(zv);
/* Create new zval, which contains the key */
if (hash_key->nKeyLength) {
zend_hash_update(target, hash_key->arKey, hash_key->nKeyLength, zv, sizeof(zval *), NULL);
} else {
zend_hash_index_update(target, *next_long_index_p, zv, sizeof(zval *), NULL);
(*next_long_index_p)++;
}
return ZEND_HASH_APPLY_KEEP;
}
/* Put the flipped key->val to the table, which is passed as additional argument */
static int vo_callback_make_syncFieldsMap(zval **zv TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key)
{
zval *new_zval;
HashTable *target = va_arg(args, HashTable*);
int *next_long_index_p = va_arg(args, int*);
/* Create new zval, which contains the key */
ALLOC_INIT_ZVAL(new_zval);
if (hash_key->nKeyLength) {
ZVAL_STRINGL(new_zval, hash_key->arKey, hash_key->nKeyLength - 1, TRUE);
} else {
ZVAL_LONG(new_zval, hash_key->h);
}
/* Put it either under hash string, or index, depending on zval extracted.
"update" is used instead of "add", so we don't need to react, if the key already exists */
switch (Z_TYPE_PP(zv)) {
case IS_STRING:
zend_hash_update(target, Z_STRVAL_PP(zv), Z_STRLEN_PP(zv) + 1, &new_zval, sizeof(zval *), NULL);
break;
case IS_LONG:
zend_hash_index_update(target, *next_long_index_p, &new_zval, sizeof(zval *), NULL);
(*next_long_index_p)++;
break;
default:
zval_ptr_dtor(&new_zval);
php_error_docref(NULL TSRMLS_CC, E_WARNING, "oldFieldsMap must contain only STRING or INTEGER values!");
}
return ZEND_HASH_APPLY_KEEP;
}
/* protected function _addFullNames() */
PHP_METHOD(Varien_Object, _addFullNames)
{
/*
---PHP---
$existedShortKeys = array_intersect($this->_syncFieldsMap, array_keys($this->_data));
if (!empty($existedShortKeys)) {
foreach ($existedShortKeys as $key) {
$fullFieldName = array_search($key, $this->_syncFieldsMap);
$this->_data[$fullFieldName] = $this->_data[$key];
}
}
---Interpretation---
Go through keys of _data, write each synced value under synced key
*/
zval *obj_zval = getThis();
zval **data;
zval **syncFieldsMap;
int num_sync_elements;
int num_data_elements;
int total_to_sync, i;
HashTable *ht_data, *ht_syncFieldsMap;
int current_key_type;
ulong current_index;
char *current_key;
uint current_key_len;
zval **found_zval;
int found_result;
zval **sync_to;
typedef struct {
char *key_name;
uint key_name_len;
ulong key_hash;
zval *value;
} key_info_t;
key_info_t *copy_to_keys;
key_info_t *key_info;
/* Extract and check properties */
VO_EXTRACT_PROPERTY(_data, obj_zval, &data);
if (Z_TYPE_PP(data) != IS_ARRAY) {
php_error_docref(NULL TSRMLS_CC, E_ERROR, "_data property must be array");
}
num_data_elements = zend_hash_num_elements(Z_ARRVAL_PP(data));
if (!num_data_elements) {
return;
}
VO_EXTRACT_PROPERTY(_syncFieldsMap, obj_zval, &syncFieldsMap);
if (!syncFieldsMap || !(*syncFieldsMap) || (Z_TYPE_PP(syncFieldsMap) != IS_ARRAY)) {
php_error_docref(NULL TSRMLS_CC, E_ERROR, "_syncFieldsMap property must be array");
}
ht_syncFieldsMap = Z_ARRVAL_PP(syncFieldsMap);
num_sync_elements = zend_hash_num_elements(ht_syncFieldsMap);
if (!num_sync_elements) {
return;
}
/* Iterate over syncFieldsMap and find the keys, to which we will sync values from _data. */
SEPARATE_ZVAL_IF_NOT_REF(data);
ht_data = Z_ARRVAL_PP(data);
copy_to_keys = emalloc(num_sync_elements * sizeof(key_info_t)); /* Allocate maximal possible array to hold things we will sync */
total_to_sync = 0;
for (zend_hash_internal_pointer_reset(ht_syncFieldsMap); zend_hash_has_more_elements(ht_syncFieldsMap) == SUCCESS; zend_hash_move_forward(ht_syncFieldsMap)) {
/* Extract current key */
current_key_type = zend_hash_get_current_key_ex(ht_syncFieldsMap, ¤t_key, ¤t_key_len, ¤t_index, FALSE, NULL);
/* Try to extract the value at _data[key]. Success means, that we have something to sync. */
if (current_key_type == HASH_KEY_IS_LONG) {
found_result = zend_hash_index_find(ht_data, current_index, (void **) &found_zval);
} else {
found_result = zend_hash_find(ht_data, current_key, current_key_len, (void **) &found_zval);
}
if (found_result == FAILURE) {
continue;
}
/* Extract the "sync to" from _syncFieldsMap - i.e. the key, where the data value must be synced to */
zend_hash_get_current_data(ht_syncFieldsMap, (void **) &sync_to);
key_info = ©_to_keys[total_to_sync];
switch (Z_TYPE_PP(sync_to)) {
case IS_LONG:
key_info->key_name = NULL;
key_info->key_hash = Z_LVAL_PP(sync_to);
break;
case IS_STRING:
key_info->key_name = Z_STRVAL_PP(sync_to);
key_info->key_name_len = Z_STRLEN_PP(sync_to);
break;
default:
efree(copy_to_keys);
php_error_docref(NULL TSRMLS_CC, E_ERROR, "_syncFieldsMap entries may be of INTEGER or STRING type only");
break;
}
key_info->value = *found_zval;
total_to_sync++;
}
/* Now go through the extracted keys and sync the values to them */
for (i = 0; i < total_to_sync; i++) {
key_info = ©_to_keys[i];
/* Prepare zval to be synced to another key */
Z_ADDREF_P(key_info->value);
if (Z_ISREF_P(key_info->value)) {
SEPARATE_ZVAL(&key_info->value);
}
/* Copy value to synced key */
if (key_info->key_name == NULL) {
zend_hash_index_update(ht_data, key_info->key_hash, &key_info->value, sizeof(zval *), NULL);
} else {
zend_hash_update(ht_data, key_info->key_name, key_info->key_name_len + 1, &key_info->value, sizeof(zval *), NULL);
}
}
}
/* protected function _construct() */
PHP_METHOD(Varien_Object, _construct)
{
}
/* Check whether key contains '/', and if true, then accept $key = 'a/b/c' as query for $this->_data['a']['b']['c'] */
int getData_fetch_by_path_key(zval *data, zval *key_param, zval *return_value TSRMLS_DC)
{
/*
---PHP---
if (strpos($key,'/')) {
$keyArr = explode('/', $key);
$data = $this->_data;
foreach ($keyArr as $i=>$k) {
if ($k==='') {
return $default;
}
if (is_array($data)) {
if (!isset($data[$k])) {
return $default;
}
$data = $data[$k];
} elseif ($data instanceof Varien_Object) {
$data = $data->getData($k);
} else {
return $default;
}
}
return $data;
}
*/
zend_uchar key_param_type;
char *key_str;
uint key_str_len;
const char *found;
char *search_key, *current_key, *key_end;
uint current_key_len;
zval **current_zval;
HashTable *ht;
int result;
zval *param_zval;
zval *tmp_retval, *call_retval = NULL;
#define RELEASE_CALL_RETVAL if (call_retval) {zval_ptr_dtor(&call_retval); call_retval = NULL;}
/* Optimization - if key of basic value, then there is no '/' in it */
key_param_type = key_param ? Z_TYPE_P(key_param) : IS_NULL;
switch (key_param_type) {
case IS_NULL:
case IS_LONG:
case IS_DOUBLE:
case IS_BOOL:
return FALSE;
}
/* Convert key param to string. Note: key_param is considered an independent variable. */
convert_to_string(key_param);
key_str = Z_STRVAL_P(key_param);
key_str_len = Z_STRLEN_P(key_param);
/* Algorithm */
key_end = key_str + key_str_len - 1;
found = php_memnstr(key_str, "/", 1, key_end);
if (!found) {
return FALSE;
}
current_key = key_str;
current_key_len = found - current_key;
current_zval = &data;
do {
if (!current_key_len) {
RELEASE_CALL_RETVAL;
RETVAL_NULL();
return TRUE;
}
if (Z_TYPE_PP(current_zval) == IS_ARRAY) {
ht = Z_ARRVAL_PP(current_zval);
search_key = estrndup(current_key, current_key_len); /* So we have key with "\0" at end, which is needed for array hash */
result = zend_symtable_find(ht, search_key, current_key_len + 1, (void **) ¤t_zval);
efree(search_key);
if (result == FAILURE) {
RELEASE_CALL_RETVAL;
RETVAL_NULL();
return TRUE;
}
} else if ((Z_TYPE_PP(current_zval) == IS_OBJECT) && (instanceof_function(Z_OBJCE_PP(current_zval), vo_class TSRMLS_CC))) {
ALLOC_INIT_ZVAL(param_zval);
ZVAL_STRINGL(param_zval, current_key, current_key_len, TRUE);
zend_call_method_with_1_params(current_zval, Z_OBJCE_PP(current_zval), NULL, "getdata", &tmp_retval, param_zval);
zval_ptr_dtor(¶m_zval);
RELEASE_CALL_RETVAL;