You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

94 lines
4.0 KiB

20 years ago
  1. /*
  2. +----------------------------------------------------------------------+
  3. | Zend Engine |
  4. +----------------------------------------------------------------------+
  5. | Copyright (c) 1998-2007 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. /* $Id$ */
  20. #ifndef ZEND_OBJECTS_API_H
  21. #define ZEND_OBJECTS_API_H
  22. #include "zend.h"
  23. typedef void (*zend_objects_store_dtor_t)(void *object, zend_object_handle handle TSRMLS_DC);
  24. typedef void (*zend_objects_free_object_storage_t)(void *object TSRMLS_DC);
  25. typedef void (*zend_objects_store_clone_t)(void *object, void **object_clone TSRMLS_DC);
  26. typedef struct _zend_object_store_bucket {
  27. zend_bool destructor_called;
  28. zend_bool valid;
  29. union _store_bucket {
  30. struct _store_object {
  31. void *object;
  32. zend_objects_store_dtor_t dtor;
  33. zend_objects_free_object_storage_t free_storage;
  34. zend_objects_store_clone_t clone;
  35. zend_uint refcount;
  36. } obj;
  37. struct {
  38. int next;
  39. } free_list;
  40. } bucket;
  41. } zend_object_store_bucket;
  42. typedef struct _zend_objects_store {
  43. zend_object_store_bucket *object_buckets;
  44. zend_uint top;
  45. zend_uint size;
  46. int free_list_head;
  47. } zend_objects_store;
  48. /* Global store handling functions */
  49. BEGIN_EXTERN_C()
  50. ZEND_API void zend_objects_store_init(zend_objects_store *objects, zend_uint init_size);
  51. ZEND_API void zend_objects_store_call_destructors(zend_objects_store *objects TSRMLS_DC);
  52. ZEND_API void zend_objects_store_mark_destructed(zend_objects_store *objects TSRMLS_DC);
  53. ZEND_API void zend_objects_store_destroy(zend_objects_store *objects);
  54. /* Store API functions */
  55. 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);
  56. ZEND_API void zend_objects_store_add_ref(zval *object TSRMLS_DC);
  57. ZEND_API void zend_objects_store_del_ref(zval *object TSRMLS_DC);
  58. ZEND_API void zend_objects_store_add_ref_by_handle(zend_object_handle handle TSRMLS_DC);
  59. ZEND_API void zend_objects_store_del_ref_by_handle(zend_object_handle handle TSRMLS_DC);
  60. ZEND_API zend_uint zend_objects_store_get_refcount(zval *object TSRMLS_DC);
  61. ZEND_API zend_object_value zend_objects_store_clone_obj(zval *object TSRMLS_DC);
  62. ZEND_API void *zend_object_store_get_object(zval *object TSRMLS_DC);
  63. ZEND_API void *zend_object_store_get_object_by_handle(zend_object_handle handle TSRMLS_DC);
  64. /* See comment in zend_objects_API.c before you use this */
  65. ZEND_API void zend_object_store_set_object(zval *zobject, void *object TSRMLS_DC);
  66. ZEND_API void zend_object_store_ctor_failed(zval *zobject TSRMLS_DC);
  67. ZEND_API void zend_objects_store_free_object_storage(zend_objects_store *objects TSRMLS_DC);
  68. #define ZEND_OBJECTS_STORE_HANDLERS zend_objects_store_add_ref, zend_objects_store_del_ref, zend_objects_store_clone_obj
  69. ZEND_API zval *zend_object_create_proxy(zval *object, zval *member TSRMLS_DC);
  70. ZEND_API zend_object_handlers *zend_get_std_object_handlers();
  71. END_EXTERN_C()
  72. #endif /* ZEND_OBJECTS_H */
  73. /*
  74. * Local variables:
  75. * tab-width: 4
  76. * c-basic-offset: 4
  77. * indent-tabs-mode: t
  78. * End:
  79. */