Deleted Added
full compact
zend_object_handlers.c (62bdbc0e) zend_object_handlers.c (345e0255)
1/*
2 +----------------------------------------------------------------------+
3 | Zend Engine |
4 +----------------------------------------------------------------------+
5 | Copyright (c) 1998-2004 Zend Technologies Ltd. (http://www.zend.com) |
6 +----------------------------------------------------------------------+
7 | This source file is subject to version 2.00 of the Zend license, |
8 | that is bundled with this package in the file LICENSE, and is |

--- 95 unchanged lines hidden (view full) ---

104 result = i_zend_is_true(retval) ? SUCCESS : FAILURE;
105 zval_ptr_dtor(&retval);
106 return result;
107 } else {
108 return FAILURE;
109 }
110}
111
1/*
2 +----------------------------------------------------------------------+
3 | Zend Engine |
4 +----------------------------------------------------------------------+
5 | Copyright (c) 1998-2004 Zend Technologies Ltd. (http://www.zend.com) |
6 +----------------------------------------------------------------------+
7 | This source file is subject to version 2.00 of the Zend license, |
8 | that is bundled with this package in the file LICENSE, and is |

--- 95 unchanged lines hidden (view full) ---

104 result = i_zend_is_true(retval) ? SUCCESS : FAILURE;
105 zval_ptr_dtor(&retval);
106 return result;
107 } else {
108 return FAILURE;
109 }
110}
111
112static void zend_std_call_unsetter(zval *object, zval *member TSRMLS_DC)
113{
114 zend_class_entry *ce = Z_OBJCE_P(object);
115
116 /* __unset handler is called with one argument:
117 property name
118 */
119
120 SEPARATE_ARG_IF_REF(member);
112
121
122 zend_call_method_with_1_params(&object, ce, &ce->__unset, ZEND_UNSET_FUNC_NAME, NULL, member);
123
124 zval_ptr_dtor(&member);
125}
126
127static zval *zend_std_call_issetter(zval *object, zval *member TSRMLS_DC)
128{
129 zval *retval = NULL;
130 zend_class_entry *ce = Z_OBJCE_P(object);
131
132 /* __isset handler is called with one argument:
133 property name
134
135 it should return whether the property is set or not
136 */
137
138 SEPARATE_ARG_IF_REF(member);
139
140 zend_call_method_with_1_params(&object, ce, &ce->__isset, ZEND_ISSET_FUNC_NAME, &retval, member);
141
142 zval_ptr_dtor(&member);
143
144 return retval;
145}
146
113static int zend_verify_property_access(zend_property_info *property_info, zend_class_entry *ce TSRMLS_DC)
114{
115 switch (property_info->flags & ZEND_ACC_PPP_MASK) {
116 case ZEND_ACC_PUBLIC:
117 return 1;
118 case ZEND_ACC_PROTECTED:
119 return zend_check_protected(ce, EG(scope));
120 case ZEND_ACC_PRIVATE:

--- 294 unchanged lines hidden (view full) ---

415{
416 zend_class_entry *ce = Z_OBJCE_P(object);
417 zval *retval;
418 int result;
419
420 if (instanceof_function_ex(ce, zend_ce_arrayaccess, 1 TSRMLS_CC)) {
421 SEPARATE_ARG_IF_REF(offset);
422 zend_call_method_with_1_params(&object, ce, NULL, "offsetexists", &retval, offset);
147static int zend_verify_property_access(zend_property_info *property_info, zend_class_entry *ce TSRMLS_DC)
148{
149 switch (property_info->flags & ZEND_ACC_PPP_MASK) {
150 case ZEND_ACC_PUBLIC:
151 return 1;
152 case ZEND_ACC_PROTECTED:
153 return zend_check_protected(ce, EG(scope));
154 case ZEND_ACC_PRIVATE:

--- 294 unchanged lines hidden (view full) ---

449{
450 zend_class_entry *ce = Z_OBJCE_P(object);
451 zval *retval;
452 int result;
453
454 if (instanceof_function_ex(ce, zend_ce_arrayaccess, 1 TSRMLS_CC)) {
455 SEPARATE_ARG_IF_REF(offset);
456 zend_call_method_with_1_params(&object, ce, NULL, "offsetexists", &retval, offset);
423 zval_ptr_dtor(&offset);
424 if (retval) {
425 result = i_zend_is_true(retval);
426 zval_ptr_dtor(&retval);
457 if (retval) {
458 result = i_zend_is_true(retval);
459 zval_ptr_dtor(&retval);
427 return result;
460 if (check_empty && result && !EG(exception)) {
461 zend_call_method_with_1_params(&object, ce, NULL, "offsetget", &retval, offset);
462 if (retval) {
463 result = i_zend_is_true(retval);
464 zval_ptr_dtor(&retval);
465 }
466 }
428 } else {
467 } else {
429 return 0;
468 result = 0;
430 }
469 }
470 zval_ptr_dtor(&offset);
431 } else {
432 zend_error(E_ERROR, "Cannot use object of type %s as array", ce->name);
433 return 0;
434 }
471 } else {
472 zend_error(E_ERROR, "Cannot use object of type %s as array", ce->name);
473 return 0;
474 }
475 return result;
435}
436
437
438static zval **zend_std_get_property_ptr_ptr(zval *object, zval *member TSRMLS_DC)
439{
440 zend_object *zobj;
441 zval tmp_member;
442 zval **retval;

--- 34 unchanged lines hidden (view full) ---

477 }
478 return retval;
479}
480
481
482static void zend_std_unset_property(zval *object, zval *member TSRMLS_DC)
483{
484 zend_object *zobj;
476}
477
478
479static zval **zend_std_get_property_ptr_ptr(zval *object, zval *member TSRMLS_DC)
480{
481 zend_object *zobj;
482 zval tmp_member;
483 zval **retval;

--- 34 unchanged lines hidden (view full) ---

518 }
519 return retval;
520}
521
522
523static void zend_std_unset_property(zval *object, zval *member TSRMLS_DC)
524{
525 zend_object *zobj;
485 zval tmp_member;
526 zval *tmp_member = NULL;
486 zend_property_info *property_info;
527 zend_property_info *property_info;
528 zend_bool use_unset;
487
488 zobj = Z_OBJ_P(object);
529
530 zobj = Z_OBJ_P(object);
531 use_unset = (zobj->ce->__unset && !zobj->in_unset);
489
490 if (member->type != IS_STRING) {
532
533 if (member->type != IS_STRING) {
491 tmp_member = *member;
492 zval_copy_ctor(&tmp_member);
493 convert_to_string(&tmp_member);
494 member = &tmp_member;
534 ALLOC_ZVAL(tmp_member);
535 *tmp_member = *member;
536 INIT_PZVAL(tmp_member);
537 zval_copy_ctor(tmp_member);
538 convert_to_string(tmp_member);
539 member = tmp_member;
495 }
496
497 property_info = zend_get_property_info(zobj->ce, member, 0 TSRMLS_CC);
498
540 }
541
542 property_info = zend_get_property_info(zobj->ce, member, 0 TSRMLS_CC);
543
499 zend_hash_del(zobj->properties, property_info->name, property_info->name_length+1);
500 if (member == &tmp_member) {
501 zval_dtor(member);
544 if (!property_info || zend_hash_del(zobj->properties, property_info->name, property_info->name_length+1) == FAILURE) {
545 if (use_unset) {
546 /* have unseter - try with it! */
547 zobj->in_unset = 1; /* prevent circular unsetting */
548 zend_std_call_unsetter(object, member TSRMLS_CC);
549 zobj->in_unset = 0;
550 }
502 }
551 }
552
553 if (tmp_member) {
554 zval_ptr_dtor(&tmp_member);
555 }
503}
504
505
506static void zend_std_unset_dimension(zval *object, zval *offset TSRMLS_DC)
507{
508 zend_class_entry *ce = Z_OBJCE_P(object);
509
510 if (instanceof_function_ex(ce, zend_ce_arrayaccess, 1 TSRMLS_CC)) {

--- 321 unchanged lines hidden (view full) ---

832 return zend_compare_symbol_tables_i(zobj1->properties, zobj2->properties TSRMLS_CC);
833}
834
835static int zend_std_has_property(zval *object, zval *member, int has_set_exists TSRMLS_DC)
836{
837 zend_object *zobj;
838 int result;
839 zval **value;
556}
557
558
559static void zend_std_unset_dimension(zval *object, zval *offset TSRMLS_DC)
560{
561 zend_class_entry *ce = Z_OBJCE_P(object);
562
563 if (instanceof_function_ex(ce, zend_ce_arrayaccess, 1 TSRMLS_CC)) {

--- 321 unchanged lines hidden (view full) ---

885 return zend_compare_symbol_tables_i(zobj1->properties, zobj2->properties TSRMLS_CC);
886}
887
888static int zend_std_has_property(zval *object, zval *member, int has_set_exists TSRMLS_DC)
889{
890 zend_object *zobj;
891 int result;
892 zval **value;
840 zval tmp_member;
893 zval *tmp_member = NULL;
841 zend_property_info *property_info;
894 zend_property_info *property_info;
895 zend_bool use_isset;
842
843 zobj = Z_OBJ_P(object);
896
897 zobj = Z_OBJ_P(object);
898 use_isset = (zobj->ce->__isset && !zobj->in_isset);
844
845 if (member->type != IS_STRING) {
899
900 if (member->type != IS_STRING) {
846 tmp_member = *member;
847 zval_copy_ctor(&tmp_member);
848 convert_to_string(&tmp_member);
849 member = &tmp_member;
901 ALLOC_ZVAL(tmp_member);
902 *tmp_member = *member;
903 INIT_PZVAL(tmp_member);
904 zval_copy_ctor(tmp_member);
905 convert_to_string(tmp_member);
906 member = tmp_member;
850 }
851
852#if DEBUG_OBJECT_HANDLERS
853 fprintf(stderr, "Read object #%d property: %s\n", Z_OBJ_HANDLE_P(object), Z_STRVAL_P(member));
854#endif
855
907 }
908
909#if DEBUG_OBJECT_HANDLERS
910 fprintf(stderr, "Read object #%d property: %s\n", Z_OBJ_HANDLE_P(object), Z_STRVAL_P(member));
911#endif
912
856 if (!(property_info = zend_get_property_info(zobj->ce, member, 1 TSRMLS_CC))) {
857 return 0;
858 }
913 property_info = zend_get_property_info(zobj->ce, member, 1 TSRMLS_CC);
859
914
860 if (zend_hash_find(zobj->properties, property_info->name, property_info->name_length+1, (void **) &value) == SUCCESS) {
915 if (!property_info || zend_hash_quick_find(zobj->properties, property_info->name, property_info->name_length+1, property_info->h, (void **) &value) == FAILURE) {
916 result = 0;
917 if (use_isset && (has_set_exists != 2)) {
918 zval *rv;
919
920 /* have issetter - try with it! */
921 zobj->in_isset = 1; /* prevent circular getting */
922 rv = zend_std_call_issetter(object, member TSRMLS_CC);
923 zobj->in_isset = 0;
924 if (rv) {
925 result = zend_is_true(rv);
926 zval_ptr_dtor(&rv);
927 if (has_set_exists && result && !EG(exception) && zobj->ce->__get && !zobj->in_get) {
928 rv = zend_std_call_getter(object, member TSRMLS_CC);
929 if (rv) {
930 rv->refcount++;
931 result = i_zend_is_true(rv);
932 zval_ptr_dtor(&rv);
933 }
934 }
935 }
936 }
937 } else {
861 switch (has_set_exists) {
862 case 0:
863 result = (Z_TYPE_PP(value) != IS_NULL);
864 break;
865 default:
866 result = zend_is_true(*value);
867 break;
868 case 2:
869 result = 1;
870 break;
871 }
938 switch (has_set_exists) {
939 case 0:
940 result = (Z_TYPE_PP(value) != IS_NULL);
941 break;
942 default:
943 result = zend_is_true(*value);
944 break;
945 case 2:
946 result = 1;
947 break;
948 }
872 } else {
873 result = 0;
874 }
875
949 }
950
876 if (member == &tmp_member) {
877 zval_dtor(member);
951 if (tmp_member) {
952 zval_ptr_dtor(&tmp_member);
878 }
879 return result;
880}
881
882
883zend_class_entry *zend_std_object_get_class(zval *object TSRMLS_DC)
884{
885 zend_object *zobj;

--- 92 unchanged lines hidden ---
953 }
954 return result;
955}
956
957
958zend_class_entry *zend_std_object_get_class(zval *object TSRMLS_DC)
959{
960 zend_object *zobj;

--- 92 unchanged lines hidden ---