2006-05-10 07:53:23 +08:00
|
|
|
/*
|
2003-02-01 09:49:15 +08:00
|
|
|
+----------------------------------------------------------------------+
|
|
|
|
| Zend Engine |
|
|
|
|
+----------------------------------------------------------------------+
|
2011-01-01 10:17:06 +08:00
|
|
|
| Copyright (c) 1998-2011 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-05-31 20:09:19 +08:00
|
|
|
#ifndef ZEND_OBJECTS_API_H
|
|
|
|
#define ZEND_OBJECTS_API_H
|
|
|
|
|
|
|
|
#include "zend.h"
|
|
|
|
|
|
|
|
typedef void (*zend_objects_store_dtor_t)(void *object, zend_object_handle handle TSRMLS_DC);
|
2005-02-25 02:40:19 +08:00
|
|
|
typedef void (*zend_objects_free_object_storage_t)(void *object TSRMLS_DC);
|
2002-05-31 20:09:19 +08:00
|
|
|
typedef void (*zend_objects_store_clone_t)(void *object, void **object_clone TSRMLS_DC);
|
|
|
|
|
|
|
|
typedef struct _zend_object_store_bucket {
|
|
|
|
zend_bool destructor_called;
|
2004-02-04 20:30:48 +08:00
|
|
|
zend_bool valid;
|
2002-05-31 20:09:19 +08:00
|
|
|
union _store_bucket {
|
|
|
|
struct _store_object {
|
|
|
|
void *object;
|
|
|
|
zend_objects_store_dtor_t dtor;
|
2004-02-04 17:56:20 +08:00
|
|
|
zend_objects_free_object_storage_t free_storage;
|
2002-05-31 20:09:19 +08:00
|
|
|
zend_objects_store_clone_t clone;
|
2008-08-25 00:49:19 +08:00
|
|
|
const zend_object_handlers *handlers;
|
2002-05-31 20:09:19 +08:00
|
|
|
zend_uint refcount;
|
2008-01-22 17:27:48 +08:00
|
|
|
gc_root_buffer *buffered;
|
2002-05-31 20:09:19 +08:00
|
|
|
} obj;
|
|
|
|
struct {
|
|
|
|
int next;
|
|
|
|
} free_list;
|
|
|
|
} bucket;
|
|
|
|
} zend_object_store_bucket;
|
|
|
|
|
|
|
|
typedef struct _zend_objects_store {
|
|
|
|
zend_object_store_bucket *object_buckets;
|
|
|
|
zend_uint top;
|
|
|
|
zend_uint size;
|
|
|
|
int free_list_head;
|
|
|
|
} zend_objects_store;
|
|
|
|
|
|
|
|
/* Global store handling functions */
|
2004-02-19 06:44:40 +08:00
|
|
|
BEGIN_EXTERN_C()
|
2002-08-09 01:53:32 +08:00
|
|
|
ZEND_API void zend_objects_store_init(zend_objects_store *objects, zend_uint init_size);
|
|
|
|
ZEND_API void zend_objects_store_call_destructors(zend_objects_store *objects TSRMLS_DC);
|
2004-09-17 18:13:52 +08:00
|
|
|
ZEND_API void zend_objects_store_mark_destructed(zend_objects_store *objects TSRMLS_DC);
|
2002-08-09 01:53:32 +08:00
|
|
|
ZEND_API void zend_objects_store_destroy(zend_objects_store *objects);
|
2002-05-31 20:09:19 +08:00
|
|
|
|
|
|
|
/* Store API functions */
|
2004-02-04 17:56:20 +08:00
|
|
|
ZEND_API zend_object_handle zend_objects_store_put(void *object, zend_objects_store_dtor_t dtor, zend_objects_free_object_storage_t storage, zend_objects_store_clone_t clone TSRMLS_DC);
|
2002-05-31 20:09:19 +08:00
|
|
|
|
2002-08-09 01:53:32 +08:00
|
|
|
ZEND_API void zend_objects_store_add_ref(zval *object TSRMLS_DC);
|
|
|
|
ZEND_API void zend_objects_store_del_ref(zval *object TSRMLS_DC);
|
2006-05-10 07:53:23 +08:00
|
|
|
ZEND_API void zend_objects_store_add_ref_by_handle(zend_object_handle handle TSRMLS_DC);
|
2008-08-25 00:49:19 +08:00
|
|
|
ZEND_API void zend_objects_store_del_ref_by_handle_ex(zend_object_handle handle, const zend_object_handlers *handlers TSRMLS_DC);
|
2010-04-20 19:16:39 +08:00
|
|
|
static zend_always_inline void zend_objects_store_del_ref_by_handle(zend_object_handle handle TSRMLS_DC) {
|
2008-08-25 00:49:19 +08:00
|
|
|
zend_objects_store_del_ref_by_handle_ex(handle, NULL TSRMLS_CC);
|
|
|
|
}
|
2006-08-07 23:15:22 +08:00
|
|
|
ZEND_API zend_uint zend_objects_store_get_refcount(zval *object TSRMLS_DC);
|
2002-08-09 01:53:32 +08:00
|
|
|
ZEND_API zend_object_value zend_objects_store_clone_obj(zval *object TSRMLS_DC);
|
2008-08-13 01:20:25 +08:00
|
|
|
ZEND_API void *zend_object_store_get_object(const zval *object TSRMLS_DC);
|
2006-05-10 07:53:23 +08:00
|
|
|
ZEND_API void *zend_object_store_get_object_by_handle(zend_object_handle handle TSRMLS_DC);
|
2004-05-17 19:27:16 +08:00
|
|
|
/* See comment in zend_objects_API.c before you use this */
|
|
|
|
ZEND_API void zend_object_store_set_object(zval *zobject, void *object TSRMLS_DC);
|
2004-07-26 01:25:44 +08:00
|
|
|
ZEND_API void zend_object_store_ctor_failed(zval *zobject TSRMLS_DC);
|
2004-05-17 19:27:16 +08:00
|
|
|
|
2004-02-04 17:56:20 +08:00
|
|
|
ZEND_API void zend_objects_store_free_object_storage(zend_objects_store *objects TSRMLS_DC);
|
|
|
|
|
2004-02-03 23:37:37 +08:00
|
|
|
#define ZEND_OBJECTS_STORE_HANDLERS zend_objects_store_add_ref, zend_objects_store_del_ref, zend_objects_store_clone_obj
|
2002-05-31 20:09:19 +08:00
|
|
|
|
2004-03-22 02:27:58 +08:00
|
|
|
ZEND_API zval *zend_object_create_proxy(zval *object, zval *member TSRMLS_DC);
|
2003-01-18 05:16:12 +08:00
|
|
|
|
2007-07-21 08:35:15 +08:00
|
|
|
ZEND_API zend_object_handlers *zend_get_std_object_handlers(void);
|
2004-02-19 06:44:40 +08:00
|
|
|
END_EXTERN_C()
|
|
|
|
|
2002-05-31 20:09:19 +08:00
|
|
|
#endif /* ZEND_OBJECTS_H */
|
2003-02-01 09:49:15 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Local variables:
|
|
|
|
* tab-width: 4
|
|
|
|
* c-basic-offset: 4
|
|
|
|
* indent-tabs-mode: t
|
|
|
|
* End:
|
|
|
|
*/
|