Back to index

php5  5.3.10
Classes | Defines | Typedefs | Functions | Variables
zend_interfaces.h File Reference
#include "zend.h"
#include "zend_API.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _zend_user_iterator

Defines

#define zend_call_method_with_0_params(obj, obj_ce, fn_proxy, function_name, retval)   zend_call_method(obj, obj_ce, fn_proxy, function_name, sizeof(function_name)-1, retval, 0, NULL, NULL TSRMLS_CC)
#define zend_call_method_with_1_params(obj, obj_ce, fn_proxy, function_name, retval, arg1)   zend_call_method(obj, obj_ce, fn_proxy, function_name, sizeof(function_name)-1, retval, 1, arg1, NULL TSRMLS_CC)
#define zend_call_method_with_2_params(obj, obj_ce, fn_proxy, function_name, retval, arg1, arg2)   zend_call_method(obj, obj_ce, fn_proxy, function_name, sizeof(function_name)-1, retval, 2, arg1, arg2 TSRMLS_CC)

Typedefs

typedef struct _zend_user_iterator zend_user_iterator

Functions

ZEND_API zval * zend_call_method (zval **object_pp, zend_class_entry *obj_ce, zend_function **fn_proxy, char *function_name, int function_name_len, zval **retval_ptr_ptr, int param_count, zval *arg1, zval *arg2 TSRMLS_DC)
ZEND_API void zend_user_it_rewind (zend_object_iterator *_iter TSRMLS_DC)
ZEND_API int zend_user_it_valid (zend_object_iterator *_iter TSRMLS_DC)
ZEND_API int zend_user_it_get_current_key (zend_object_iterator *_iter, char **str_key, uint *str_key_len, ulong *int_key TSRMLS_DC)
ZEND_API void zend_user_it_get_current_data (zend_object_iterator *_iter, zval ***data TSRMLS_DC)
ZEND_API void zend_user_it_move_forward (zend_object_iterator *_iter TSRMLS_DC)
ZEND_API void zend_user_it_invalidate_current (zend_object_iterator *_iter TSRMLS_DC)
ZEND_API zval * zend_user_it_new_iterator (zend_class_entry *ce, zval *object TSRMLS_DC)
ZEND_API zend_object_iterator * zend_user_it_get_new_iterator (zend_class_entry *ce, zval *object, int by_ref TSRMLS_DC)
ZEND_API void zend_register_interfaces (TSRMLS_D)
ZEND_API int zend_user_serialize (zval *object, unsigned char **buffer, zend_uint *buf_len, zend_serialize_data *data TSRMLS_DC)
ZEND_API int zend_user_unserialize (zval **object, zend_class_entry *ce, const unsigned char *buf, zend_uint buf_len, zend_unserialize_data *data TSRMLS_DC)
ZEND_API int zend_class_serialize_deny (zval *object, unsigned char **buffer, zend_uint *buf_len, zend_serialize_data *data TSRMLS_DC)
ZEND_API int zend_class_unserialize_deny (zval **object, zend_class_entry *ce, const unsigned char *buf, zend_uint buf_len, zend_unserialize_data *data TSRMLS_DC)

Variables

ZEND_API zend_class_entry * zend_ce_traversable
ZEND_API zend_class_entry * zend_ce_aggregate
ZEND_API zend_class_entry * zend_ce_iterator
ZEND_API zend_class_entry * zend_ce_arrayaccess
ZEND_API zend_class_entry * zend_ce_serializable

Class Documentation

struct _zend_user_iterator

Definition at line 35 of file zend_interfaces.h.

Class Members
zend_class_entry * ce
zend_object_iterator it
zval * value

Define Documentation

#define zend_call_method_with_0_params (   obj,
  obj_ce,
  fn_proxy,
  function_name,
  retval 
)    zend_call_method(obj, obj_ce, fn_proxy, function_name, sizeof(function_name)-1, retval, 0, NULL, NULL TSRMLS_CC)

Definition at line 43 of file zend_interfaces.h.

#define zend_call_method_with_1_params (   obj,
  obj_ce,
  fn_proxy,
  function_name,
  retval,
  arg1 
)    zend_call_method(obj, obj_ce, fn_proxy, function_name, sizeof(function_name)-1, retval, 1, arg1, NULL TSRMLS_CC)

Definition at line 46 of file zend_interfaces.h.

#define zend_call_method_with_2_params (   obj,
  obj_ce,
  fn_proxy,
  function_name,
  retval,
  arg1,
  arg2 
)    zend_call_method(obj, obj_ce, fn_proxy, function_name, sizeof(function_name)-1, retval, 2, arg1, arg2 TSRMLS_CC)

Definition at line 49 of file zend_interfaces.h.


Typedef Documentation


Function Documentation

ZEND_API zval* zend_call_method ( zval **  object_pp,
zend_class_entry *  obj_ce,
zend_function **  fn_proxy,
char *  function_name,
int  function_name_len,
zval **  retval_ptr_ptr,
int  param_count,
zval *  arg1,
zval *arg2  TSRMLS_DC 
)

Definition at line 34 of file zend_interfaces.c.

{
       int result;
       zend_fcall_info fci;
       zval z_fname;
       zval *retval;
       HashTable *function_table;

       zval **params[2];

       params[0] = &arg1;
       params[1] = &arg2;

       fci.size = sizeof(fci);
       /*fci.function_table = NULL; will be read form zend_class_entry of object if needed */
       fci.object_ptr = object_pp ? *object_pp : NULL;
       fci.function_name = &z_fname;
       fci.retval_ptr_ptr = retval_ptr_ptr ? retval_ptr_ptr : &retval;
       fci.param_count = param_count;
       fci.params = params;
       fci.no_separation = 1;
       fci.symbol_table = NULL;

       if (!fn_proxy && !obj_ce) {
              /* no interest in caching and no information already present that is
               * needed later inside zend_call_function. */
              ZVAL_STRINGL(&z_fname, function_name, function_name_len, 0);
              fci.function_table = !object_pp ? EG(function_table) : NULL;
              result = zend_call_function(&fci, NULL TSRMLS_CC);
       } else {
              zend_fcall_info_cache fcic;

              fcic.initialized = 1;
              if (!obj_ce) {
                     obj_ce = object_pp ? Z_OBJCE_PP(object_pp) : NULL;
              }
              if (obj_ce) {
                     function_table = &obj_ce->function_table;
              } else {
                     function_table = EG(function_table);
              }
              if (!fn_proxy || !*fn_proxy) {
                     if (zend_hash_find(function_table, function_name, function_name_len+1, (void **) &fcic.function_handler) == FAILURE) {
                            /* error at c-level */
                            zend_error(E_CORE_ERROR, "Couldn't find implementation for method %s%s%s", obj_ce ? obj_ce->name : "", obj_ce ? "::" : "", function_name);
                     }
                     if (fn_proxy) {
                            *fn_proxy = fcic.function_handler;
                     }
              } else {
                     fcic.function_handler = *fn_proxy;
              }
              fcic.calling_scope = obj_ce;
              if (object_pp) {
                     fcic.called_scope = Z_OBJCE_PP(object_pp);
              } else if (obj_ce &&
                         !(EG(called_scope) &&
                           instanceof_function(EG(called_scope), obj_ce TSRMLS_CC))) {
                     fcic.called_scope = obj_ce;
              } else {
                     fcic.called_scope = EG(called_scope);
              }
              fcic.object_ptr = object_pp ? *object_pp : NULL;
              result = zend_call_function(&fci, &fcic TSRMLS_CC);
       }
       if (result == FAILURE) {
              /* error at c-level */
              if (!obj_ce) {
                     obj_ce = object_pp ? Z_OBJCE_PP(object_pp) : NULL;
              }
              if (!EG(exception)) {
                     zend_error(E_CORE_ERROR, "Couldn't execute method %s%s%s", obj_ce ? obj_ce->name : "", obj_ce ? "::" : "", function_name);
              }
       }
       if (!retval_ptr_ptr) {
              if (retval) {
                     zval_ptr_dtor(&retval);
              }
              return NULL;
       }
       return *retval_ptr_ptr;
}

Here is the call graph for this function:

Here is the caller graph for this function:

ZEND_API int zend_class_serialize_deny ( zval *  object,
unsigned char **  buffer,
zend_uint buf_len,
zend_serialize_data *data  TSRMLS_DC 
)

Definition at line 484 of file zend_interfaces.c.

{
       zend_class_entry *ce = Z_OBJCE_P(object);
       zend_throw_exception_ex(NULL, 0 TSRMLS_CC, "Serialization of '%s' is not allowed", ce->name);
       return FAILURE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

ZEND_API int zend_class_unserialize_deny ( zval **  object,
zend_class_entry *  ce,
const unsigned char *  buf,
zend_uint  buf_len,
zend_unserialize_data *data  TSRMLS_DC 
)

Definition at line 492 of file zend_interfaces.c.

{
       zend_throw_exception_ex(NULL, 0 TSRMLS_CC, "Unserialization of '%s' is not allowed", ce->name);
       return FAILURE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 578 of file zend_interfaces.c.

Here is the caller graph for this function:

ZEND_API void zend_user_it_get_current_data ( zend_object_iterator *  _iter,
zval ***data  TSRMLS_DC 
)

Definition at line 175 of file zend_interfaces.c.

{
       zend_user_iterator *iter = (zend_user_iterator*)_iter;
       zval *object = (zval*)iter->it.data;

       if (!iter->value) {
              zend_call_method_with_0_params(&object, iter->ce, &iter->ce->iterator_funcs.zf_current, "current", &iter->value);
       }
       *data = &iter->value;
}

Here is the caller graph for this function:

ZEND_API int zend_user_it_get_current_key ( zend_object_iterator *  _iter,
char **  str_key,
uint str_key_len,
ulong *int_key  TSRMLS_DC 
)

Definition at line 198 of file zend_interfaces.c.

{
       zend_user_iterator *iter = (zend_user_iterator*)_iter;
       zval *object = (zval*)iter->it.data;
       zval *retval;

       zend_call_method_with_0_params(&object, iter->ce, &iter->ce->iterator_funcs.zf_key, "key", &retval);

       if (!retval) {
              *int_key = 0;
              if (!EG(exception))
              {
                     zend_error(E_WARNING, "Nothing returned from %s::key()", iter->ce->name);
              }
              return HASH_KEY_IS_LONG;
       }
       switch (Z_TYPE_P(retval)) {
              default:
                     zend_error(E_WARNING, "Illegal type returned from %s::key()", iter->ce->name);
              case IS_NULL:
                     *int_key = 0;
                     zval_ptr_dtor(&retval);
                     return HASH_KEY_IS_LONG;

              case IS_STRING:
                     *str_key = estrndup(Z_STRVAL_P(retval), Z_STRLEN_P(retval));
                     *str_key_len = Z_STRLEN_P(retval)+1;
                     zval_ptr_dtor(&retval);
                     return HASH_KEY_IS_STRING;

              case IS_DOUBLE:
                     *int_key = (long)Z_DVAL_P(retval);
                     zval_ptr_dtor(&retval);
                     return HASH_KEY_IS_LONG;

              case IS_RESOURCE:
              case IS_BOOL:
              case IS_LONG:
                     *int_key = (long)Z_LVAL_P(retval);
                     zval_ptr_dtor(&retval);
                     return HASH_KEY_IS_LONG;
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

ZEND_API zend_object_iterator* zend_user_it_get_new_iterator ( zend_class_entry *  ce,
zval *  object,
int by_ref  TSRMLS_DC 
)

Definition at line 296 of file zend_interfaces.c.

{
       zval *iterator = zend_user_it_new_iterator(ce, object TSRMLS_CC);
       zend_object_iterator *new_iterator;

       zend_class_entry *ce_it = iterator && Z_TYPE_P(iterator) == IS_OBJECT ? Z_OBJCE_P(iterator) : NULL;

       if (!ce_it || !ce_it->get_iterator || (ce_it->get_iterator == zend_user_it_get_new_iterator && iterator == object)) {
              if (!EG(exception)) {
                     zend_throw_exception_ex(NULL, 0 TSRMLS_CC, "Objects returned by %s::getIterator() must be traversable or implement interface Iterator", ce ? ce->name : Z_OBJCE_P(object)->name);
              }
              if (iterator) {
                     zval_ptr_dtor(&iterator);
              }
              return NULL;
       }

       new_iterator = ce_it->get_iterator(ce_it, iterator, by_ref TSRMLS_CC);
       zval_ptr_dtor(&iterator);
       return new_iterator;
}

Here is the call graph for this function:

Here is the caller graph for this function:

ZEND_API void zend_user_it_invalidate_current ( zend_object_iterator *_iter  TSRMLS_DC)

Definition at line 131 of file zend_interfaces.c.

{
       zend_user_iterator *iter = (zend_user_iterator*)_iter;

       if (iter->value) {
              zval_ptr_dtor(&iter->value);
              iter->value = NULL;
       }
}

Here is the caller graph for this function:

ZEND_API void zend_user_it_move_forward ( zend_object_iterator *_iter  TSRMLS_DC)

Definition at line 244 of file zend_interfaces.c.

{
       zend_user_iterator *iter = (zend_user_iterator*)_iter;
       zval *object = (zval*)iter->it.data;

       zend_user_it_invalidate_current(_iter TSRMLS_CC);
       zend_call_method_with_0_params(&object, iter->ce, &iter->ce->iterator_funcs.zf_next, "next", NULL);
}

Here is the call graph for this function:

Here is the caller graph for this function:

ZEND_API zval* zend_user_it_new_iterator ( zend_class_entry *  ce,
zval *object  TSRMLS_DC 
)

Definition at line 121 of file zend_interfaces.c.

{
       zval *retval;

       return zend_call_method_with_0_params(&object, ce, &ce->iterator_funcs.zf_new_iterator, "getiterator", &retval);

}

Here is the caller graph for this function:

ZEND_API void zend_user_it_rewind ( zend_object_iterator *_iter  TSRMLS_DC)

Definition at line 255 of file zend_interfaces.c.

{
       zend_user_iterator *iter = (zend_user_iterator*)_iter;
       zval *object = (zval*)iter->it.data;

       zend_user_it_invalidate_current(_iter TSRMLS_CC);
       zend_call_method_with_0_params(&object, iter->ce, &iter->ce->iterator_funcs.zf_rewind, "rewind", NULL);
}

Here is the call graph for this function:

Here is the caller graph for this function:

ZEND_API int zend_user_it_valid ( zend_object_iterator *_iter  TSRMLS_DC)

Definition at line 155 of file zend_interfaces.c.

{
       if (_iter) {
              zend_user_iterator *iter = (zend_user_iterator*)_iter;
              zval *object = (zval*)iter->it.data;
              zval *more;
              int result;

              zend_call_method_with_0_params(&object, iter->ce, &iter->ce->iterator_funcs.zf_valid, "valid", &more);
              if (more) {
                     result = i_zend_is_true(more);
                     zval_ptr_dtor(&more);
                     return result ? SUCCESS : FAILURE;
              }
       }
       return FAILURE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

ZEND_API int zend_user_serialize ( zval *  object,
unsigned char **  buffer,
zend_uint buf_len,
zend_serialize_data *data  TSRMLS_DC 
)

Definition at line 426 of file zend_interfaces.c.

{
       zend_class_entry * ce = Z_OBJCE_P(object);
       zval *retval;
       int result;

       zend_call_method_with_0_params(&object, ce, &ce->serialize_func, "serialize", &retval);


       if (!retval || EG(exception)) {
              result = FAILURE;
       } else {
              switch(Z_TYPE_P(retval)) {
              case IS_NULL:
                     /* we could also make this '*buf_len = 0' but this allows to skip variables */
                     zval_ptr_dtor(&retval);
                     return FAILURE;
              case IS_STRING:
                     *buffer = (unsigned char*)estrndup(Z_STRVAL_P(retval), Z_STRLEN_P(retval));
                     *buf_len = Z_STRLEN_P(retval);
                     result = SUCCESS;
                     break;
              default: /* failure */
                     result = FAILURE;
                     break;
              }
              zval_ptr_dtor(&retval);
       }

       if (result == FAILURE) {
              zend_throw_exception_ex(NULL, 0 TSRMLS_CC, "%s::serialize() must return a string or NULL", ce->name);
       }
       return result;
}

Here is the call graph for this function:

Here is the caller graph for this function:

ZEND_API int zend_user_unserialize ( zval **  object,
zend_class_entry *  ce,
const unsigned char *  buf,
zend_uint  buf_len,
zend_unserialize_data *data  TSRMLS_DC 
)

Definition at line 463 of file zend_interfaces.c.

{
       zval * zdata;

       object_init_ex(*object, ce);

       MAKE_STD_ZVAL(zdata);
       ZVAL_STRINGL(zdata, (char*)buf, buf_len, 1);

       zend_call_method_with_1_params(object, ce, &ce->unserialize_func, "unserialize", NULL, zdata);

       zval_ptr_dtor(&zdata);

       if (EG(exception)) {
              return FAILURE;
       } else {
              return SUCCESS;
       }
}

Here is the caller graph for this function:


Variable Documentation

ZEND_API zend_class_entry* zend_ce_aggregate

Definition at line 27 of file zend_interfaces.c.

ZEND_API zend_class_entry* zend_ce_arrayaccess

Definition at line 29 of file zend_interfaces.c.

ZEND_API zend_class_entry* zend_ce_iterator

Definition at line 28 of file zend_interfaces.c.

ZEND_API zend_class_entry* zend_ce_serializable

Definition at line 30 of file zend_interfaces.c.

ZEND_API zend_class_entry* zend_ce_traversable

Definition at line 26 of file zend_interfaces.c.