Line data Source code
1 : /*
2 : +----------------------------------------------------------------------+
3 : | Zend Engine |
4 : +----------------------------------------------------------------------+
5 : | Copyright (c) 1998-2015 Zend Technologies Ltd. (http://www.zend.com) |
6 : +----------------------------------------------------------------------+
7 : | This source file is subject to version 2.00 of the Zend license, |
8 : | that is bundled with this package in the file LICENSE, and is |
9 : | available through the world-wide-web at the following url: |
10 : | http://www.zend.com/license/2_00.txt. |
11 : | If you did not receive a copy of the Zend license and are unable to |
12 : | obtain it through the world-wide-web, please send a note to |
13 : | license@zend.com so we can mail you a copy immediately. |
14 : +----------------------------------------------------------------------+
15 : | Authors: Andi Gutmans <andi@zend.com> |
16 : | Zeev Suraski <zeev@zend.com> |
17 : +----------------------------------------------------------------------+
18 : */
19 :
20 : /* $Id$ */
21 :
22 : #ifndef ZEND_OBJECTS_API_H
23 : #define ZEND_OBJECTS_API_H
24 :
25 : #include "zend.h"
26 :
27 : typedef void (*zend_objects_store_dtor_t)(void *object, zend_object_handle handle TSRMLS_DC);
28 : typedef void (*zend_objects_free_object_storage_t)(void *object TSRMLS_DC);
29 : typedef void (*zend_objects_store_clone_t)(void *object, void **object_clone TSRMLS_DC);
30 :
31 : typedef struct _zend_object_store_bucket {
32 : zend_bool destructor_called;
33 : zend_bool valid;
34 : zend_uchar apply_count;
35 : union _store_bucket {
36 : struct _store_object {
37 : void *object;
38 : zend_objects_store_dtor_t dtor;
39 : zend_objects_free_object_storage_t free_storage;
40 : zend_objects_store_clone_t clone;
41 : const zend_object_handlers *handlers;
42 : zend_uint refcount;
43 : gc_root_buffer *buffered;
44 : } obj;
45 : struct {
46 : int next;
47 : } free_list;
48 : } bucket;
49 : } zend_object_store_bucket;
50 :
51 : typedef struct _zend_objects_store {
52 : zend_object_store_bucket *object_buckets;
53 : zend_uint top;
54 : zend_uint size;
55 : int free_list_head;
56 : } zend_objects_store;
57 :
58 : /* Global store handling functions */
59 : BEGIN_EXTERN_C()
60 : ZEND_API void zend_objects_store_init(zend_objects_store *objects, zend_uint init_size);
61 : ZEND_API void zend_objects_store_call_destructors(zend_objects_store *objects TSRMLS_DC);
62 : ZEND_API void zend_objects_store_mark_destructed(zend_objects_store *objects TSRMLS_DC);
63 : ZEND_API void zend_objects_store_destroy(zend_objects_store *objects);
64 :
65 : /* Store API functions */
66 : 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);
67 :
68 : ZEND_API void zend_objects_store_add_ref(zval *object TSRMLS_DC);
69 : ZEND_API void zend_objects_store_del_ref(zval *object TSRMLS_DC);
70 : ZEND_API void zend_objects_store_add_ref_by_handle(zend_object_handle handle TSRMLS_DC);
71 : ZEND_API void zend_objects_store_del_ref_by_handle_ex(zend_object_handle handle, const zend_object_handlers *handlers TSRMLS_DC);
72 313 : static zend_always_inline void zend_objects_store_del_ref_by_handle(zend_object_handle handle TSRMLS_DC) {
73 313 : zend_objects_store_del_ref_by_handle_ex(handle, NULL TSRMLS_CC);
74 313 : }
75 : ZEND_API zend_uint zend_objects_store_get_refcount(zval *object TSRMLS_DC);
76 : ZEND_API zend_object_value zend_objects_store_clone_obj(zval *object TSRMLS_DC);
77 : ZEND_API void *zend_object_store_get_object(const zval *object TSRMLS_DC);
78 : ZEND_API void *zend_object_store_get_object_by_handle(zend_object_handle handle TSRMLS_DC);
79 : /* See comment in zend_objects_API.c before you use this */
80 : ZEND_API void zend_object_store_set_object(zval *zobject, void *object TSRMLS_DC);
81 : ZEND_API void zend_object_store_ctor_failed(zval *zobject TSRMLS_DC);
82 :
83 : ZEND_API void zend_objects_store_free_object_storage(zend_objects_store *objects TSRMLS_DC);
84 :
85 : #define ZEND_OBJECTS_STORE_HANDLERS zend_objects_store_add_ref, zend_objects_store_del_ref, zend_objects_store_clone_obj
86 :
87 : ZEND_API zval *zend_object_create_proxy(zval *object, zval *member TSRMLS_DC);
88 :
89 : ZEND_API zend_object_handlers *zend_get_std_object_handlers(void);
90 : END_EXTERN_C()
91 :
92 : #endif /* ZEND_OBJECTS_H */
93 :
94 : /*
95 : * Local variables:
96 : * tab-width: 4
97 : * c-basic-offset: 4
98 : * indent-tabs-mode: t
99 : * End:
100 : */
|