diff options
Diffstat (limited to 'Zend/zend_object_handlers.h')
-rw-r--r-- | Zend/zend_object_handlers.h | 120 |
1 files changed, 73 insertions, 47 deletions
diff --git a/Zend/zend_object_handlers.h b/Zend/zend_object_handlers.h index acc4b7575f..770a67cbdd 100644 --- a/Zend/zend_object_handlers.h +++ b/Zend/zend_object_handlers.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | Zend Engine | +----------------------------------------------------------------------+ - | Copyright (c) 1998-2018 Zend Technologies Ltd. (http://www.zend.com) | + | Copyright (c) Zend Technologies Ltd. (http://www.zend.com) | +----------------------------------------------------------------------+ | This source file is subject to version 2.00 of the Zend license, | | that is bundled with this package in the file LICENSE, and is | @@ -51,9 +51,10 @@ typedef zval *(*zend_object_read_dimension_t)(zval *object, zval *offset, int ty If you receive a value zval in write_property/write_dimension, you may only modify it if its reference count is 1. Otherwise, you must create a copy of that zval before making any changes. You should NOT modify the reference count of the value passed to you. + You must return the final value of the assigned property. */ /* Used to set property of the object */ -typedef void (*zend_object_write_property_t)(zval *object, zval *member, zval *value, void **cache_slot); +typedef zval *(*zend_object_write_property_t)(zval *object, zval *member, zval *value, void **cache_slot); /* Used to set dimension of the object */ typedef void (*zend_object_write_dimension_t)(zval *object, zval *offset, zval *value); @@ -93,6 +94,28 @@ typedef HashTable *(*zend_object_get_properties_t)(zval *object); typedef HashTable *(*zend_object_get_debug_info_t)(zval *object, int *is_temp); +typedef enum _zend_prop_purpose { + /* Used for debugging. Supersedes get_debug_info handler. */ + ZEND_PROP_PURPOSE_DEBUG, + /* Used for (array) casts. */ + ZEND_PROP_PURPOSE_ARRAY_CAST, + /* Used for serialization using the "O" scheme. + * Unserialization will use __wakeup(). */ + ZEND_PROP_PURPOSE_SERIALIZE, + /* Used for var_export(). + * The data will be passed to __set_state() when evaluated. */ + ZEND_PROP_PURPOSE_VAR_EXPORT, + /* Used for json_encode(). */ + ZEND_PROP_PURPOSE_JSON, + /* array_key_exists(). Not intended for general use! */ + _ZEND_PROP_PURPOSE_ARRAY_KEY_EXISTS, + /* Dummy member to ensure that "default" is specified. */ + _ZEND_PROP_PURPOSE_NON_EXHAUSTIVE_ENUM +} zend_prop_purpose; + +/* The return value must be released using zend_release_properties(). */ +typedef zend_array *(*zend_object_get_properties_for_t)(zval *object, zend_prop_purpose purpose); + /* Used to call methods */ /* args on stack! */ /* Andi - EX(fbc) (function being called) needs to be initialized already in the INIT fcall opcode so that the parameters can be parsed the right way. We need to add another callback for this. @@ -111,7 +134,7 @@ typedef zend_object* (*zend_object_clone_obj_t)(zval *object); typedef zend_string *(*zend_object_get_class_name_t)(const zend_object *object); typedef int (*zend_object_compare_t)(zval *object1, zval *object2); -typedef int (*zend_object_compare_zvals_t)(zval *resul, zval *op1, zval *op2); +typedef int (*zend_object_compare_zvals_t)(zval *result, zval *op1, zval *op2); /* Cast an object to some other type. * readobj and retval must point to distinct zvals. @@ -131,35 +154,35 @@ typedef int (*zend_object_do_operation_t)(zend_uchar opcode, zval *result, zval struct _zend_object_handlers { /* offset of real object header (usually zero) */ int offset; - /* general object functions */ - zend_object_free_obj_t free_obj; - zend_object_dtor_obj_t dtor_obj; - zend_object_clone_obj_t clone_obj; - /* individual object functions */ - zend_object_read_property_t read_property; - zend_object_write_property_t write_property; - zend_object_read_dimension_t read_dimension; - zend_object_write_dimension_t write_dimension; - zend_object_get_property_ptr_ptr_t get_property_ptr_ptr; - zend_object_get_t get; - zend_object_set_t set; - zend_object_has_property_t has_property; - zend_object_unset_property_t unset_property; - zend_object_has_dimension_t has_dimension; - zend_object_unset_dimension_t unset_dimension; - zend_object_get_properties_t get_properties; - zend_object_get_method_t get_method; - zend_object_call_method_t call_method; - zend_object_get_constructor_t get_constructor; - zend_object_get_class_name_t get_class_name; - zend_object_compare_t compare_objects; - zend_object_cast_t cast_object; - zend_object_count_elements_t count_elements; - zend_object_get_debug_info_t get_debug_info; - zend_object_get_closure_t get_closure; - zend_object_get_gc_t get_gc; - zend_object_do_operation_t do_operation; - zend_object_compare_zvals_t compare; + /* object handlers */ + zend_object_free_obj_t free_obj; /* required */ + zend_object_dtor_obj_t dtor_obj; /* required */ + zend_object_clone_obj_t clone_obj; /* optional */ + zend_object_read_property_t read_property; /* required */ + zend_object_write_property_t write_property; /* required */ + zend_object_read_dimension_t read_dimension; /* required */ + zend_object_write_dimension_t write_dimension; /* required */ + zend_object_get_property_ptr_ptr_t get_property_ptr_ptr; /* required */ + zend_object_get_t get; /* optional */ + zend_object_set_t set; /* optional */ + zend_object_has_property_t has_property; /* required */ + zend_object_unset_property_t unset_property; /* required */ + zend_object_has_dimension_t has_dimension; /* required */ + zend_object_unset_dimension_t unset_dimension; /* required */ + zend_object_get_properties_t get_properties; /* required */ + zend_object_get_method_t get_method; /* required */ + zend_object_call_method_t call_method; /* optional */ + zend_object_get_constructor_t get_constructor; /* required */ + zend_object_get_class_name_t get_class_name; /* required */ + zend_object_compare_t compare_objects; /* optional */ + zend_object_cast_t cast_object; /* optional */ + zend_object_count_elements_t count_elements; /* optional */ + zend_object_get_debug_info_t get_debug_info; /* optional */ + zend_object_get_closure_t get_closure; /* optional */ + zend_object_get_gc_t get_gc; /* required */ + zend_object_do_operation_t do_operation; /* optional */ + zend_object_compare_zvals_t compare; /* optional */ + zend_object_get_properties_for_t get_properties_for; /* optional */ }; BEGIN_EXTERN_C() @@ -177,7 +200,8 @@ extern const ZEND_API zend_object_handlers std_object_handlers; ZEND_API void zend_class_init_statics(zend_class_entry *ce); ZEND_API zend_function *zend_std_get_static_method(zend_class_entry *ce, zend_string *function_name_strval, const zval *key); -ZEND_API zval *zend_std_get_static_property(zend_class_entry *ce, zend_string *property_name, zend_bool silent); +ZEND_API zval *zend_std_get_static_property_with_info(zend_class_entry *ce, zend_string *property_name, int type, struct _zend_property_info **prop_info); +ZEND_API zval *zend_std_get_static_property(zend_class_entry *ce, zend_string *property_name, int type); ZEND_API ZEND_COLD zend_bool zend_std_unset_static_property(zend_class_entry *ce, zend_string *property_name); ZEND_API zend_function *zend_std_get_constructor(zend_object *object); ZEND_API struct _zend_property_info *zend_get_property_info(zend_class_entry *ce, zend_string *member, int silent); @@ -187,7 +211,7 @@ ZEND_API HashTable *zend_std_get_debug_info(zval *object, int *is_temp); ZEND_API int zend_std_cast_object_tostring(zval *readobj, zval *writeobj, int type); ZEND_API zval *zend_std_get_property_ptr_ptr(zval *object, zval *member, int type, void **cache_slot); ZEND_API zval *zend_std_read_property(zval *object, zval *member, int type, void **cache_slot, zval *rv); -ZEND_API void zend_std_write_property(zval *object, zval *member, zval *value, void **cache_slot); +ZEND_API zval *zend_std_write_property(zval *object, zval *member, zval *value, void **cache_slot); ZEND_API int zend_std_has_property(zval *object, zval *member, int has_set_exists, void **cache_slot); ZEND_API void zend_std_unset_property(zval *object, zval *member, void **cache_slot); ZEND_API zval *zend_std_read_dimension(zval *object, zval *offset, int type, zval *rv); @@ -200,16 +224,28 @@ ZEND_API int zend_std_compare_objects(zval *o1, zval *o2); ZEND_API int zend_std_get_closure(zval *obj, zend_class_entry **ce_ptr, zend_function **fptr_ptr, zend_object **obj_ptr); ZEND_API void rebuild_object_properties(zend_object *zobj); -ZEND_API int zend_check_private(zend_function *fbc, zend_class_entry *ce, zend_string *function_name); - ZEND_API int zend_check_protected(zend_class_entry *ce, zend_class_entry *scope); -ZEND_API int zend_check_property_access(zend_object *zobj, zend_string *prop_info_name); +ZEND_API int zend_check_property_access(zend_object *zobj, zend_string *prop_info_name, zend_bool is_dynamic); ZEND_API zend_function *zend_get_call_trampoline_func(zend_class_entry *ce, zend_string *method_name, int is_static); ZEND_API uint32_t *zend_get_property_guard(zend_object *zobj, zend_string *member); +/* Default behavior for get_properties_for. For use as a fallback in custom + * get_properties_for implementations. */ +ZEND_API HashTable *zend_std_get_properties_for(zval *obj, zend_prop_purpose purpose); + +/* Will call get_properties_for handler or use default behavior. For use by + * consumers of the get_properties_for API. */ +ZEND_API HashTable *zend_get_properties_for(zval *obj, zend_prop_purpose purpose); + +#define zend_release_properties(ht) do { \ + if ((ht) && !(GC_FLAGS(ht) & GC_IMMUTABLE) && !GC_DELREF(ht)) { \ + zend_array_destroy(ht); \ + } \ +} while (0) + #define zend_free_trampoline(func) do { \ if ((func) == &EG(trampoline)) { \ EG(trampoline).common.function_name = NULL; \ @@ -221,13 +257,3 @@ ZEND_API uint32_t *zend_get_property_guard(zend_object *zobj, zend_string *membe END_EXTERN_C() #endif - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * indent-tabs-mode: t - * End: - * vim600: sw=4 ts=4 fdm=marker - * vim<600: sw=4 ts=4 - */ |