Back to index

php5  5.3.10
zend_object_handlers.h
Go to the documentation of this file.
00001 /*
00002    +----------------------------------------------------------------------+
00003    | Zend Engine                                                          |
00004    +----------------------------------------------------------------------+
00005    | Copyright (c) 1998-2012 Zend Technologies Ltd. (http://www.zend.com) |
00006    +----------------------------------------------------------------------+
00007    | This source file is subject to version 2.00 of the Zend license,     |
00008    | that is bundled with this package in the file LICENSE, and is        |
00009    | available through the world-wide-web at the following url:           |
00010    | http://www.zend.com/license/2_00.txt.                                |
00011    | If you did not receive a copy of the Zend license and are unable to  |
00012    | obtain it through the world-wide-web, please send a note to          |
00013    | license@zend.com so we can mail you a copy immediately.              |
00014    +----------------------------------------------------------------------+
00015    | Authors: Andi Gutmans <andi@zend.com>                                |
00016    |          Zeev Suraski <zeev@zend.com>                                |
00017    +----------------------------------------------------------------------+
00018 */
00019 
00020 /* $Id: zend_object_handlers.h 321634 2012-01-01 13:15:04Z felipe $ */
00021 
00022 #ifndef ZEND_OBJECT_HANDLERS_H
00023 #define ZEND_OBJECT_HANDLERS_H
00024 
00025 union _zend_function;
00026 struct _zend_property_info;
00027 
00028 /* The following rule applies to read_property() and read_dimension() implementations:
00029    If you return a zval which is not otherwise referenced by the extension or the engine's
00030    symbol table, its reference count should be 0.
00031 */
00032 /* Used to fetch property from the object, read-only */
00033 typedef zval *(*zend_object_read_property_t)(zval *object, zval *member, int type TSRMLS_DC);
00034 
00035 /* Used to fetch dimension from the object, read-only */
00036 typedef zval *(*zend_object_read_dimension_t)(zval *object, zval *offset, int type TSRMLS_DC);
00037 
00038 
00039 /* The following rule applies to write_property() and write_dimension() implementations:
00040    If you receive a value zval in write_property/write_dimension, you may only modify it if
00041    its reference count is 1.  Otherwise, you must create a copy of that zval before making
00042    any changes.  You should NOT modify the reference count of the value passed to you.
00043 */
00044 /* Used to set property of the object */
00045 typedef void (*zend_object_write_property_t)(zval *object, zval *member, zval *value TSRMLS_DC);
00046 
00047 /* Used to set dimension of the object */
00048 typedef void (*zend_object_write_dimension_t)(zval *object, zval *offset, zval *value TSRMLS_DC);
00049 
00050 
00051 /* Used to create pointer to the property of the object, for future direct r/w access */
00052 typedef zval **(*zend_object_get_property_ptr_ptr_t)(zval *object, zval *member TSRMLS_DC);
00053 
00054 /* Used to set object value. Can be used to override assignments and scalar
00055    write ops (like ++, +=) on the object */
00056 typedef void (*zend_object_set_t)(zval **object, zval *value TSRMLS_DC);
00057 
00058 /* Used to get object value. Can be used when converting object value to
00059  * one of the basic types and when using scalar ops (like ++, +=) on the object
00060  */
00061 typedef zval* (*zend_object_get_t)(zval *object TSRMLS_DC);
00062 
00063 /* Used to check if a property of the object exists */
00064 /* param has_set_exists:
00065  * 0 (has) whether property exists and is not NULL
00066  * 1 (set) whether property exists and is true
00067  * 2 (exists) whether property exists
00068  */
00069 typedef int (*zend_object_has_property_t)(zval *object, zval *member, int has_set_exists TSRMLS_DC);
00070 
00071 /* Used to check if a dimension of the object exists */
00072 typedef int (*zend_object_has_dimension_t)(zval *object, zval *member, int check_empty TSRMLS_DC);
00073 
00074 /* Used to remove a property of the object */
00075 typedef void (*zend_object_unset_property_t)(zval *object, zval *member TSRMLS_DC);
00076 
00077 /* Used to remove a dimension of the object */
00078 typedef void (*zend_object_unset_dimension_t)(zval *object, zval *offset TSRMLS_DC);
00079 
00080 /* Used to get hash of the properties of the object, as hash of zval's */
00081 typedef HashTable *(*zend_object_get_properties_t)(zval *object TSRMLS_DC);
00082 
00083 typedef HashTable *(*zend_object_get_debug_info_t)(zval *object, int *is_temp TSRMLS_DC);
00084 
00085 /* Used to call methods */
00086 /* args on stack! */
00087 /* 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.
00088  */
00089 typedef int (*zend_object_call_method_t)(char *method, INTERNAL_FUNCTION_PARAMETERS);
00090 typedef union _zend_function *(*zend_object_get_method_t)(zval **object_ptr, char *method, int method_len TSRMLS_DC);
00091 typedef union _zend_function *(*zend_object_get_constructor_t)(zval *object TSRMLS_DC);
00092 
00093 /* Object maintenance/destruction */
00094 typedef void (*zend_object_add_ref_t)(zval *object TSRMLS_DC);
00095 typedef void (*zend_object_del_ref_t)(zval *object TSRMLS_DC);
00096 typedef void (*zend_object_delete_obj_t)(zval *object TSRMLS_DC);
00097 typedef zend_object_value (*zend_object_clone_obj_t)(zval *object TSRMLS_DC);
00098 
00099 typedef zend_class_entry *(*zend_object_get_class_entry_t)(const zval *object TSRMLS_DC);
00100 typedef int (*zend_object_get_class_name_t)(const zval *object, char **class_name, zend_uint *class_name_len, int parent TSRMLS_DC);
00101 typedef int (*zend_object_compare_t)(zval *object1, zval *object2 TSRMLS_DC);
00102 
00103 /* Cast an object to some other type
00104  */
00105 typedef int (*zend_object_cast_t)(zval *readobj, zval *retval, int type TSRMLS_DC);
00106 
00107 /* updates *count to hold the number of elements present and returns SUCCESS.
00108  * Returns FAILURE if the object does not have any sense of overloaded dimensions */
00109 typedef int (*zend_object_count_elements_t)(zval *object, long *count TSRMLS_DC);
00110 
00111 typedef int (*zend_object_get_closure_t)(zval *obj, zend_class_entry **ce_ptr, union _zend_function **fptr_ptr, zval **zobj_ptr TSRMLS_DC);
00112 
00113 struct _zend_object_handlers {
00114        /* general object functions */
00115        zend_object_add_ref_t                                   add_ref;
00116        zend_object_del_ref_t                                   del_ref;
00117        zend_object_clone_obj_t                                 clone_obj;
00118        /* individual object functions */
00119        zend_object_read_property_t                      read_property;
00120        zend_object_write_property_t                     write_property;
00121        zend_object_read_dimension_t                     read_dimension;
00122        zend_object_write_dimension_t                    write_dimension;
00123        zend_object_get_property_ptr_ptr_t        get_property_ptr_ptr;
00124        zend_object_get_t                                       get;
00125        zend_object_set_t                                       set;
00126        zend_object_has_property_t                       has_property;
00127        zend_object_unset_property_t                     unset_property;
00128        zend_object_has_dimension_t                      has_dimension;
00129        zend_object_unset_dimension_t                    unset_dimension;
00130        zend_object_get_properties_t                     get_properties;
00131        zend_object_get_method_t                         get_method;
00132        zend_object_call_method_t                        call_method;
00133        zend_object_get_constructor_t                    get_constructor;
00134        zend_object_get_class_entry_t                    get_class_entry;
00135        zend_object_get_class_name_t                     get_class_name;
00136        zend_object_compare_t                                   compare_objects;
00137        zend_object_cast_t                                      cast_object;
00138        zend_object_count_elements_t                     count_elements;
00139        zend_object_get_debug_info_t                     get_debug_info;
00140        zend_object_get_closure_t                        get_closure;
00141 };
00142 
00143 extern ZEND_API zend_object_handlers std_object_handlers;
00144 
00145 BEGIN_EXTERN_C()
00146 ZEND_API union _zend_function *zend_std_get_static_method(zend_class_entry *ce, char *function_name_strval, int function_name_strlen TSRMLS_DC);
00147 ZEND_API zval **zend_std_get_static_property(zend_class_entry *ce, char *property_name, int property_name_len, zend_bool silent TSRMLS_DC);
00148 ZEND_API zend_bool zend_std_unset_static_property(zend_class_entry *ce, char *property_name, int property_name_len TSRMLS_DC);
00149 ZEND_API union _zend_function *zend_std_get_constructor(zval *object TSRMLS_DC);
00150 ZEND_API struct _zend_property_info *zend_get_property_info(zend_class_entry *ce, zval *member, int silent TSRMLS_DC);
00151 ZEND_API HashTable *zend_std_get_properties(zval *object TSRMLS_DC);
00152 ZEND_API HashTable *zend_std_get_debug_info(zval *object, int *is_temp TSRMLS_DC);
00153 ZEND_API int zend_std_cast_object_tostring(zval *readobj, zval *writeobj, int type TSRMLS_DC);
00154 
00155 
00156 #define IS_ZEND_STD_OBJECT(z)  (Z_TYPE(z) == IS_OBJECT && (Z_OBJ_HT((z))->get_class_entry != NULL))
00157 #define HAS_CLASS_ENTRY(z) (Z_OBJ_HT(z)->get_class_entry != NULL)
00158 
00159 ZEND_API int zend_check_private(union _zend_function *fbc, zend_class_entry *ce, char *function_name_strval, int function_name_strlen TSRMLS_DC);
00160 
00161 ZEND_API int zend_check_protected(zend_class_entry *ce, zend_class_entry *scope);
00162 
00163 ZEND_API int zend_check_property_access(zend_object *zobj, char *prop_info_name, int prop_info_name_len TSRMLS_DC);
00164 
00165 ZEND_API void zend_std_call_user_call(INTERNAL_FUNCTION_PARAMETERS);
00166 END_EXTERN_C()
00167 
00168 #endif
00169 
00170 /*
00171  * Local variables:
00172  * tab-width: 4
00173  * c-basic-offset: 4
00174  * indent-tabs-mode: t
00175  * End:
00176  */