2006-05-10 07:53:23 +08:00
/*
2003-02-01 09:49:15 +08:00
+ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
| Zend Engine |
+ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
2016-01-02 17:56:11 +08:00
| Copyright ( c ) 1998 - 2016 Zend Technologies Ltd . ( http : //www.zend.com) |
2003-02-01 09:49:15 +08:00
+ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
| 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 |
2003-06-11 04:04:29 +08:00
| available through the world - wide - web at the following url : |
2003-02-01 09:49:15 +08:00
| http : //www.zend.com/license/2_00.txt. |
| If you did not receive a copy of the Zend license and are unable to |
| obtain it through the world - wide - web , please send a note to |
| license @ zend . com so we can mail you a copy immediately . |
+ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
| Authors : Andi Gutmans < andi @ zend . com > |
| Zeev Suraski < zeev @ zend . com > |
+ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
*/
/* $Id$ */
2002-02-07 22:08:43 +08:00
# ifndef ZEND_OBJECT_HANDLERS_H
# define ZEND_OBJECT_HANDLERS_H
2005-04-08 19:35:11 +08:00
struct _zend_property_info ;
2002-02-07 22:08:43 +08:00
2014-10-17 23:10:05 +08:00
# define ZEND_WRONG_PROPERTY_INFO \
( ( struct _zend_property_info * ) ( ( zend_intptr_t ) - 1 ) )
2016-04-29 18:43:43 +08:00
# define ZEND_DYNAMIC_PROPERTY_OFFSET ((uint32_t)(-1))
# define ZEND_WRONG_PROPERTY_OFFSET ((uint32_t)(-2))
2015-01-13 16:33:00 +08:00
2004-02-12 20:22:45 +08:00
/* The following rule applies to read_property() and read_dimension() implementations:
If you return a zval which is not otherwise referenced by the extension or the engine ' s
symbol table , its reference count should be 0.
*/
2002-02-07 22:08:43 +08:00
/* Used to fetch property from the object, read-only */
2014-12-14 06:06:14 +08:00
typedef zval * ( * zend_object_read_property_t ) ( zval * object , zval * member , int type , void * * cache_slot , zval * rv ) ;
2003-07-07 17:00:36 +08:00
2003-07-07 18:53:27 +08:00
/* Used to fetch dimension from the object, read-only */
2014-12-14 06:06:14 +08:00
typedef zval * ( * zend_object_read_dimension_t ) ( zval * object , zval * offset , int type , zval * rv ) ;
2003-07-07 18:53:27 +08:00
2004-02-12 20:22:45 +08:00
/* The following rule applies to write_property() and write_dimension() implementations:
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 .
*/
2002-02-07 22:08:43 +08:00
/* Used to set property of the object */
2014-12-14 06:06:14 +08:00
typedef void ( * zend_object_write_property_t ) ( zval * object , zval * member , zval * value , void * * cache_slot ) ;
2003-07-07 17:00:36 +08:00
/* Used to set dimension of the object */
2014-12-14 06:06:14 +08:00
typedef void ( * zend_object_write_dimension_t ) ( zval * object , zval * offset , zval * value ) ;
2002-02-07 22:08:43 +08:00
2004-02-12 20:22:45 +08:00
2002-03-10 21:42:37 +08:00
/* Used to create pointer to the property of the object, for future direct r/w access */
2014-12-14 06:06:14 +08:00
typedef zval * ( * zend_object_get_property_ptr_ptr_t ) ( zval * object , zval * member , int type , void * * cache_slot ) ;
2003-07-07 17:00:36 +08:00
2004-03-28 20:05:36 +08:00
/* Used to set object value. Can be used to override assignments and scalar
write ops ( like + + , + = ) on the object */
2014-12-14 06:06:14 +08:00
typedef void ( * zend_object_set_t ) ( zval * object , zval * value ) ;
2003-07-07 17:00:36 +08:00
2004-03-28 20:05:36 +08:00
/* Used to get object value. Can be used when converting object value to
* one of the basic types and when using scalar ops ( like + + , + = ) on the object
2003-07-07 17:00:36 +08:00
*/
2014-12-14 06:06:14 +08:00
typedef zval * ( * zend_object_get_t ) ( zval * object , zval * rv ) ;
2002-02-07 22:08:43 +08:00
/* Used to check if a property of the object exists */
2005-05-03 00:18:02 +08:00
/* param has_set_exists:
2005-05-06 08:09:51 +08:00
* 0 ( has ) whether property exists and is not NULL
2005-05-03 00:18:02 +08:00
* 1 ( set ) whether property exists and is true
* 2 ( exists ) whether property exists
*/
2014-12-14 06:06:14 +08:00
typedef int ( * zend_object_has_property_t ) ( zval * object , zval * member , int has_set_exists , void * * cache_slot ) ;
2003-07-07 17:00:36 +08:00
2003-11-11 00:14:44 +08:00
/* Used to check if a dimension of the object exists */
2014-12-14 06:06:14 +08:00
typedef int ( * zend_object_has_dimension_t ) ( zval * object , zval * member , int check_empty ) ;
2003-11-11 00:14:44 +08:00
2002-02-07 22:08:43 +08:00
/* Used to remove a property of the object */
2014-12-14 06:06:14 +08:00
typedef void ( * zend_object_unset_property_t ) ( zval * object , zval * member , void * * cache_slot ) ;
2002-02-07 22:08:43 +08:00
2003-11-11 00:14:44 +08:00
/* Used to remove a dimension of the object */
2014-12-14 06:06:14 +08:00
typedef void ( * zend_object_unset_dimension_t ) ( zval * object , zval * offset ) ;
2003-07-31 01:12:06 +08:00
2002-02-07 22:08:43 +08:00
/* Used to get hash of the properties of the object, as hash of zval's */
2014-12-14 06:06:14 +08:00
typedef HashTable * ( * zend_object_get_properties_t ) ( zval * object ) ;
2002-02-07 22:08:43 +08:00
2014-12-14 06:06:14 +08:00
typedef HashTable * ( * zend_object_get_debug_info_t ) ( zval * object , int * is_temp ) ;
2007-10-11 09:03:19 +08:00
2002-02-07 22:08:43 +08:00
/* Used to call methods */
/* args on stack! */
2003-07-07 17:00:36 +08:00
/* 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.
*/
2014-03-28 06:11:22 +08:00
typedef int ( * zend_object_call_method_t ) ( zend_string * method , zend_object * object , INTERNAL_FUNCTION_PARAMETERS ) ;
2014-12-14 06:06:14 +08:00
typedef union _zend_function * ( * zend_object_get_method_t ) ( zend_object * * object , zend_string * method , const zval * key ) ;
typedef union _zend_function * ( * zend_object_get_constructor_t ) ( zend_object * object ) ;
2002-02-07 22:08:43 +08:00
/* Object maintenance/destruction */
2014-12-14 06:06:14 +08:00
typedef void ( * zend_object_dtor_obj_t ) ( zend_object * object ) ;
typedef void ( * zend_object_free_obj_t ) ( zend_object * object ) ;
typedef zend_object * ( * zend_object_clone_obj_t ) ( zval * object ) ;
2002-02-07 22:08:43 +08:00
2014-10-10 01:15:07 +08:00
/* Get class name for display in var_dump and other debugging functions.
* Must be defined and must return a non - NULL value . */
2014-12-14 06:06:14 +08:00
typedef zend_string * ( * zend_object_get_class_name_t ) ( const zend_object * object ) ;
2014-10-10 01:15:07 +08:00
2014-12-14 06:06:14 +08:00
typedef int ( * zend_object_compare_t ) ( zval * object1 , zval * object2 ) ;
typedef int ( * zend_object_compare_zvals_t ) ( zval * resul , zval * op1 , zval * op2 ) ;
2006-05-10 07:53:23 +08:00
/* Cast an object to some other type
*/
2014-12-14 06:06:14 +08:00
typedef int ( * zend_object_cast_t ) ( zval * readobj , zval * retval , int type ) ;
2003-05-28 02:52:25 +08:00
2004-05-04 23:03:28 +08:00
/* updates *count to hold the number of elements present and returns SUCCESS.
* Returns FAILURE if the object does not have any sense of overloaded dimensions */
2014-12-14 06:06:14 +08:00
typedef int ( * zend_object_count_elements_t ) ( zval * object , zend_long * count ) ;
2002-02-07 22:08:43 +08:00
2014-12-14 06:06:14 +08:00
typedef int ( * zend_object_get_closure_t ) ( zval * obj , zend_class_entry * * ce_ptr , union _zend_function * * fptr_ptr , zend_object * * obj_ptr ) ;
2008-08-15 05:36:56 +08:00
2014-12-14 06:06:14 +08:00
typedef HashTable * ( * zend_object_get_gc_t ) ( zval * object , zval * * table , int * n ) ;
2011-11-02 14:31:33 +08:00
2014-12-14 06:06:14 +08:00
typedef int ( * zend_object_do_operation_t ) ( zend_uchar opcode , zval * result , zval * op1 , zval * op2 ) ;
2013-06-17 23:48:13 +08:00
2005-12-21 05:37:52 +08:00
struct _zend_object_handlers {
2014-04-09 05:50:15 +08:00
/* offset of real object header (usually zero) */
int offset ;
2002-02-07 22:08:43 +08:00
/* general object functions */
2014-02-10 14:04:30 +08:00
zend_object_free_obj_t free_obj ;
zend_object_dtor_obj_t dtor_obj ;
2003-08-17 04:12:01 +08:00
zend_object_clone_obj_t clone_obj ;
2002-02-07 22:08:43 +08:00
/* individual object functions */
2003-07-07 17:12:15 +08:00
zend_object_read_property_t read_property ;
zend_object_write_property_t write_property ;
2003-07-07 18:53:27 +08:00
zend_object_read_dimension_t read_dimension ;
2003-07-07 17:12:15 +08:00
zend_object_write_dimension_t write_dimension ;
2003-10-05 15:52:28 +08:00
zend_object_get_property_ptr_ptr_t get_property_ptr_ptr ;
2003-07-07 17:12:15 +08:00
zend_object_get_t get ;
zend_object_set_t set ;
zend_object_has_property_t has_property ;
zend_object_unset_property_t unset_property ;
2003-11-11 00:14:44 +08:00
zend_object_has_dimension_t has_dimension ;
2003-07-31 01:12:06 +08:00
zend_object_unset_dimension_t unset_dimension ;
2003-07-07 17:12:15 +08:00
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 ;
2004-05-04 23:03:28 +08:00
zend_object_count_elements_t count_elements ;
2007-10-11 09:03:19 +08:00
zend_object_get_debug_info_t get_debug_info ;
2008-08-15 05:36:56 +08:00
zend_object_get_closure_t get_closure ;
2011-11-02 14:31:33 +08:00
zend_object_get_gc_t get_gc ;
2013-06-17 23:48:13 +08:00
zend_object_do_operation_t do_operation ;
zend_object_compare_zvals_t compare ;
2005-12-21 05:37:52 +08:00
} ;
2002-02-07 22:08:43 +08:00
2004-01-10 02:09:51 +08:00
extern ZEND_API zend_object_handlers std_object_handlers ;
2005-12-21 05:37:52 +08:00
2012-05-13 13:12:48 +08:00
# define zend_get_function_root_class(fbc) \
( ( fbc ) - > common . prototype ? ( fbc ) - > common . prototype - > common . scope : ( fbc ) - > common . scope )
2004-02-19 06:44:40 +08:00
BEGIN_EXTERN_C ( )
2014-12-14 06:06:14 +08:00
ZEND_API union _zend_function * zend_std_get_static_method ( zend_class_entry * ce , zend_string * function_name_strval , const zval * key ) ;
2015-01-13 14:33:15 +08:00
ZEND_API zval * zend_std_get_static_property ( zend_class_entry * ce , zend_string * property_name , zend_bool silent ) ;
2015-08-19 19:40:56 +08:00
ZEND_API ZEND_COLD zend_bool zend_std_unset_static_property ( zend_class_entry * ce , zend_string * property_name ) ;
2014-12-14 06:06:14 +08:00
ZEND_API union _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 ) ;
ZEND_API HashTable * zend_std_get_properties ( zval * object ) ;
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 void zend_std_write_property ( zval * object , zval * member , zval * value , void * * cache_slot ) ;
2010-05-24 22:11:39 +08:00
ZEND_API void rebuild_object_properties ( zend_object * zobj ) ;
2003-12-16 00:59:21 +08:00
2014-12-14 06:06:14 +08:00
ZEND_API int zend_check_private ( union _zend_function * fbc , zend_class_entry * ce , zend_string * function_name ) ;
2005-04-27 23:45:36 +08:00
2003-12-16 19:44:19 +08:00
ZEND_API int zend_check_protected ( zend_class_entry * ce , zend_class_entry * scope ) ;
2003-07-02 03:13:50 +08:00
2014-12-14 06:06:14 +08:00
ZEND_API int zend_check_property_access ( zend_object * zobj , zend_string * prop_info_name ) ;
2003-12-19 04:07:30 +08:00
2015-04-11 04:01:00 +08:00
ZEND_API zend_function * zend_get_call_trampoline_func ( zend_class_entry * ce , zend_string * method_name , int is_static ) ;
# define zend_free_trampoline(func) do { \
if ( ( func ) = = & EG ( trampoline ) ) { \
EG ( trampoline ) . common . function_name = NULL ; \
} else { \
efree ( func ) ; \
} \
} while ( 0 )
2004-02-19 06:44:40 +08:00
END_EXTERN_C ( )
2004-01-17 08:39:28 +08:00
2002-02-07 22:08:43 +08:00
# endif
2003-02-01 09:49:15 +08:00
/*
* Local variables :
* tab - width : 4
* c - basic - offset : 4
* indent - tabs - mode : t
* End :
*/