spl_functions.h 4.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /*
  2. +----------------------------------------------------------------------+
  3. | PHP Version 7 |
  4. +----------------------------------------------------------------------+
  5. | Copyright (c) 1997-2018 The PHP Group |
  6. +----------------------------------------------------------------------+
  7. | This source file is subject to version 3.01 of the PHP 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.php.net/license/3_01.txt |
  11. | If you did not receive a copy of the PHP license and are unable to |
  12. | obtain it through the world-wide-web, please send a note to |
  13. | license@php.net so we can mail you a copy immediately. |
  14. +----------------------------------------------------------------------+
  15. | Authors: Marcus Boerger <helly@php.net> |
  16. +----------------------------------------------------------------------+
  17. */
  18. #ifndef PHP_FUNCTIONS_H
  19. #define PHP_FUNCTIONS_H
  20. #include "php.h"
  21. typedef zend_object* (*create_object_func_t)(zend_class_entry *class_type);
  22. #define REGISTER_SPL_STD_CLASS(class_name, obj_ctor) \
  23. spl_register_std_class(&spl_ce_ ## class_name, # class_name, obj_ctor, NULL);
  24. #define REGISTER_SPL_STD_CLASS_EX(class_name, obj_ctor, funcs) \
  25. spl_register_std_class(&spl_ce_ ## class_name, # class_name, obj_ctor, funcs);
  26. #define REGISTER_SPL_SUB_CLASS_EX(class_name, parent_class_name, obj_ctor, funcs) \
  27. spl_register_sub_class(&spl_ce_ ## class_name, spl_ce_ ## parent_class_name, # class_name, obj_ctor, funcs);
  28. #define REGISTER_SPL_INTERFACE(class_name) \
  29. spl_register_interface(&spl_ce_ ## class_name, # class_name, spl_funcs_ ## class_name);
  30. #define REGISTER_SPL_IMPLEMENTS(class_name, interface_name) \
  31. zend_class_implements(spl_ce_ ## class_name, 1, spl_ce_ ## interface_name);
  32. #define REGISTER_SPL_ITERATOR(class_name) \
  33. zend_class_implements(spl_ce_ ## class_name, 1, zend_ce_iterator);
  34. #define REGISTER_SPL_PROPERTY(class_name, prop_name, prop_flags) \
  35. spl_register_property(spl_ce_ ## class_name, prop_name, sizeof(prop_name)-1, prop_flags);
  36. #define REGISTER_SPL_CLASS_CONST_LONG(class_name, const_name, value) \
  37. zend_declare_class_constant_long(spl_ce_ ## class_name, const_name, sizeof(const_name)-1, (zend_long)value);
  38. void spl_register_std_class(zend_class_entry ** ppce, char * class_name, create_object_func_t ctor, const zend_function_entry * function_list);
  39. void spl_register_sub_class(zend_class_entry ** ppce, zend_class_entry * parent_ce, char * class_name, create_object_func_t ctor, const zend_function_entry * function_list);
  40. void spl_register_interface(zend_class_entry ** ppce, char * class_name, const zend_function_entry *functions);
  41. void spl_register_property( zend_class_entry * class_entry, char *prop_name, int prop_name_len, int prop_flags);
  42. /* sub: whether to allow subclasses/interfaces
  43. allow = 0: allow all classes and interfaces
  44. allow > 0: allow all that match and mask ce_flags
  45. allow < 0: disallow all that match and mask ce_flags
  46. */
  47. void spl_add_class_name(zval * list, zend_class_entry * pce, int allow, int ce_flags);
  48. void spl_add_interfaces(zval * list, zend_class_entry * pce, int allow, int ce_flags);
  49. void spl_add_traits(zval * list, zend_class_entry * pce, int allow, int ce_flags);
  50. int spl_add_classes(zend_class_entry *pce, zval *list, int sub, int allow, int ce_flags);
  51. /* caller must efree(return) */
  52. zend_string *spl_gen_private_prop_name(zend_class_entry *ce, char *prop_name, int prop_len);
  53. #define SPL_ME(class_name, function_name, arg_info, flags) \
  54. PHP_ME( spl_ ## class_name, function_name, arg_info, flags)
  55. #define SPL_ABSTRACT_ME(class_name, function_name, arg_info) \
  56. ZEND_ABSTRACT_ME( spl_ ## class_name, function_name, arg_info)
  57. #define SPL_METHOD(class_name, function_name) \
  58. PHP_METHOD(spl_ ## class_name, function_name)
  59. #define SPL_MA(class_name, function_name, alias_class, alias_function, arg_info, flags) \
  60. PHP_MALIAS(spl_ ## alias_class, function_name, alias_function, arg_info, flags)
  61. #endif /* PHP_FUNCTIONS_H */
  62. /*
  63. * Local Variables:
  64. * c-basic-offset: 4
  65. * tab-width: 4
  66. * End:
  67. * vim600: fdm=marker
  68. * vim: noet sw=4 ts=4
  69. */