/* }}} */
typedef struct _spl_fixedarray_object { /* {{{ */
- zend_object std;
spl_fixedarray *array;
zval retval;
zend_function *fptr_offset_get;
int current;
int flags;
zend_class_entry *ce_get_iterator;
+ zend_object std;
} spl_fixedarray_object;
/* }}} */
#define SPL_FIXEDARRAY_OVERLOADED_CURRENT 0x0008
#define SPL_FIXEDARRAY_OVERLOADED_NEXT 0x0010
+static inline spl_fixedarray_object *spl_fixed_array_from_obj(zend_object *obj) /* {{{ */ {
+ return (spl_fixedarray_object*)((char*)(obj) - XtOffsetOf(spl_fixedarray_object, std));
+}
+/* }}} */
+
+#define Z_SPLFIXEDARRAY_P(zv) spl_fixed_array_from_obj(Z_OBJ_P((zv)))
+
static void spl_fixedarray_init(spl_fixedarray *array, long size TSRMLS_DC) /* {{{ */
{
if (size > 0) {
static void spl_fixedarray_object_free_storage(zend_object *object TSRMLS_DC) /* {{{ */
{
- spl_fixedarray_object *intern = (spl_fixedarray_object *)object;
+ spl_fixedarray_object *intern = spl_fixed_array_from_obj(object);
long i;
if (intern->array) {
zend_object_std_dtor(&intern->std TSRMLS_CC);
zval_ptr_dtor(&intern->retval);
- efree(object);
+ efree(intern);
}
/* }}} */
zend_class_entry *parent = class_type;
int inherited = 0;
- intern = ecalloc(1, sizeof(spl_fixedarray_object));
+ intern = ecalloc(1, sizeof(spl_fixedarray_object) + (sizeof(zval) * parent->default_properties_count - 1));
zend_object_std_init(&intern->std, class_type TSRMLS_CC);
object_properties_init(&intern->std, class_type);
intern->flags = 0;
if (orig && clone_orig) {
- spl_fixedarray_object *other = (spl_fixedarray_object*)Z_OBJ_P(orig);
+ spl_fixedarray_object *other = Z_SPLFIXEDARRAY_P(orig);
intern->ce_get_iterator = other->ce_get_iterator;
if (!other->array) {
/* leave a empty object, will be dtor later by CLONE handler */
{
spl_fixedarray_object *intern;
- intern = (spl_fixedarray_object*)Z_OBJ_P(object);
+ intern = Z_SPLFIXEDARRAY_P(object);
if (intern->fptr_offset_get) {
zval tmp, rv;
{
spl_fixedarray_object *intern;
- intern = (spl_fixedarray_object *)Z_OBJ_P(object);
+ intern = Z_SPLFIXEDARRAY_P(object);
if (intern->fptr_offset_set) {
zval tmp;
{
spl_fixedarray_object *intern;
- intern = (spl_fixedarray_object *)Z_OBJ_P(object);
+ intern = Z_SPLFIXEDARRAY_P(object);
if (intern->fptr_offset_del) {
SEPARATE_ARG_IF_REF(offset);
{
spl_fixedarray_object *intern;
- intern = (spl_fixedarray_object*)Z_OBJ_P(object);
+ intern = Z_SPLFIXEDARRAY_P(object);
if (intern->fptr_offset_get) {
zval rv;
{
spl_fixedarray_object *intern;
- intern = (spl_fixedarray_object*)Z_OBJ_P(object);
+ intern = Z_SPLFIXEDARRAY_P(object);
if (intern->fptr_count) {
zval rv;
zend_call_method_with_0_params(object, intern->std.ce, &intern->fptr_count, "count", &rv);
return;
}
- intern = (spl_fixedarray_object*)Z_OBJ_P(object);
+ intern = Z_SPLFIXEDARRAY_P(object);
if (intern->array) {
/* called __construct() twice, bail out */
*/
SPL_METHOD(SplFixedArray, __wakeup)
{
- spl_fixedarray_object *intern = (spl_fixedarray_object*)Z_OBJ_P(getThis());
+ spl_fixedarray_object *intern = Z_SPLFIXEDARRAY_P(getThis());
HashPosition ptr;
HashTable *intern_ht = zend_std_get_properties(getThis() TSRMLS_CC);
zval *data;
return;
}
- intern = (spl_fixedarray_object*)Z_OBJ_P(object);
+ intern = Z_SPLFIXEDARRAY_P(object);
if (intern->array) {
RETURN_LONG(intern->array->size);
}
return;
}
- intern = (spl_fixedarray_object*)Z_OBJ_P(getThis());
+ intern = Z_SPLFIXEDARRAY_P(getThis());
array_init(return_value);
if (intern->array) {
return;
}
- intern = (spl_fixedarray_object*)Z_OBJ_P(object);
+ intern = Z_SPLFIXEDARRAY_P(object);
if (intern->array) {
RETURN_LONG(intern->array->size);
}
return;
}
- intern = (spl_fixedarray_object*)Z_OBJ_P(object);
+ intern = Z_SPLFIXEDARRAY_P(object);
if (!intern->array) {
intern->array = ecalloc(1, sizeof(spl_fixedarray));
}
}
/* }}} */
-/* {{{ proto bool SplFixedArray::offsetExists(mixed $index) U
+/* {{{ proto bool SplFixedArray::offsetExists(mixed $index)
Returns whether the requested $index exists. */
SPL_METHOD(SplFixedArray, offsetExists)
{
return;
}
- intern = (spl_fixedarray_object*)Z_OBJ_P(getThis());
+ intern = Z_SPLFIXEDARRAY_P(getThis());
RETURN_BOOL(spl_fixedarray_object_has_dimension_helper(intern, zindex, 0 TSRMLS_CC));
} /* }}} */
-/* {{{ proto mixed SplFixedArray::offsetGet(mixed $index) U
+/* {{{ proto mixed SplFixedArray::offsetGet(mixed $index)
Returns the value at the specified $index. */
SPL_METHOD(SplFixedArray, offsetGet)
{
return;
}
- intern = (spl_fixedarray_object*)Z_OBJ_P(getThis());
+ intern = Z_SPLFIXEDARRAY_P(getThis());
value = spl_fixedarray_object_read_dimension_helper(intern, zindex TSRMLS_CC);
if (value) {
RETURN_NULL();
} /* }}} */
-/* {{{ proto void SplFixedArray::offsetSet(mixed $index, mixed $newval) U
+/* {{{ proto void SplFixedArray::offsetSet(mixed $index, mixed $newval)
Sets the value at the specified $index to $newval. */
SPL_METHOD(SplFixedArray, offsetSet)
{
return;
}
- intern = (spl_fixedarray_object*)Z_OBJ_P(getThis());
+ intern = Z_SPLFIXEDARRAY_P(getThis());
spl_fixedarray_object_write_dimension_helper(intern, zindex, value TSRMLS_CC);
} /* }}} */
-/* {{{ proto void SplFixedArray::offsetUnset(mixed $index) U
+/* {{{ proto void SplFixedArray::offsetUnset(mixed $index)
Unsets the value at the specified $index. */
SPL_METHOD(SplFixedArray, offsetUnset)
{
return;
}
- intern = (spl_fixedarray_object*)Z_OBJ_P(getThis());
+ intern = Z_SPLFIXEDARRAY_P(getThis());
spl_fixedarray_object_unset_dimension_helper(intern, zindex TSRMLS_CC);
} /* }}} */
Return current array key */
SPL_METHOD(SplFixedArray, key)
{
- spl_fixedarray_object *intern = (spl_fixedarray_object*)Z_OBJ_P(getThis());
+ spl_fixedarray_object *intern = Z_SPLFIXEDARRAY_P(getThis());
if (zend_parse_parameters_none() == FAILURE) {
return;
Move to next entry */
SPL_METHOD(SplFixedArray, next)
{
- spl_fixedarray_object *intern = (spl_fixedarray_object*)Z_OBJ_P(getThis());
+ spl_fixedarray_object *intern = Z_SPLFIXEDARRAY_P(getThis());
if (zend_parse_parameters_none() == FAILURE) {
return;
Check whether the datastructure contains more entries */
SPL_METHOD(SplFixedArray, valid)
{
- spl_fixedarray_object *intern = (spl_fixedarray_object*)Z_OBJ_P(getThis());
+ spl_fixedarray_object *intern = Z_SPLFIXEDARRAY_P(getThis());
if (zend_parse_parameters_none() == FAILURE) {
return;
Rewind the datastructure back to the start */
SPL_METHOD(SplFixedArray, rewind)
{
- spl_fixedarray_object *intern = (spl_fixedarray_object*)Z_OBJ_P(getThis());
+ spl_fixedarray_object *intern = Z_SPLFIXEDARRAY_P(getThis());
if (zend_parse_parameters_none() == FAILURE) {
return;
SPL_METHOD(SplFixedArray, current)
{
zval zindex, *value;
- spl_fixedarray_object *intern = (spl_fixedarray_object*)Z_OBJ_P(getThis());
+ spl_fixedarray_object *intern = Z_SPLFIXEDARRAY_P(getThis());
if (zend_parse_parameters_none() == FAILURE) {
return;