zend_enum.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. +----------------------------------------------------------------------+
  3. | Zend Engine |
  4. +----------------------------------------------------------------------+
  5. | Copyright (c) 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: Ilija Tovilo <ilutov@php.net> |
  16. +----------------------------------------------------------------------+
  17. */
  18. #ifndef ZEND_ENUM_H
  19. #define ZEND_ENUM_H
  20. #include "zend.h"
  21. #include "zend_types.h"
  22. BEGIN_EXTERN_C()
  23. extern ZEND_API zend_class_entry *zend_ce_unit_enum;
  24. extern ZEND_API zend_class_entry *zend_ce_backed_enum;
  25. void zend_register_enum_ce(void);
  26. void zend_enum_add_interfaces(zend_class_entry *ce);
  27. zend_object *zend_enum_new(zval *result, zend_class_entry *ce, zend_string *case_name, zval *backing_value_zv);
  28. void zend_verify_enum(zend_class_entry *ce);
  29. void zend_enum_register_funcs(zend_class_entry *ce);
  30. void zend_enum_register_props(zend_class_entry *ce);
  31. ZEND_API zend_class_entry *zend_register_internal_enum(
  32. const char *name, zend_uchar type, const zend_function_entry *functions);
  33. ZEND_API void zend_enum_add_case(zend_class_entry *ce, zend_string *case_name, zval *value);
  34. ZEND_API void zend_enum_add_case_cstr(zend_class_entry *ce, const char *name, zval *value);
  35. ZEND_API zend_object *zend_enum_get_case(zend_class_entry *ce, zend_string *name);
  36. ZEND_API zend_object *zend_enum_get_case_cstr(zend_class_entry *ce, const char *name);
  37. static zend_always_inline zval *zend_enum_fetch_case_name(zend_object *zobj)
  38. {
  39. ZEND_ASSERT(zobj->ce->ce_flags & ZEND_ACC_ENUM);
  40. return OBJ_PROP_NUM(zobj, 0);
  41. }
  42. static zend_always_inline zval *zend_enum_fetch_case_value(zend_object *zobj)
  43. {
  44. ZEND_ASSERT(zobj->ce->ce_flags & ZEND_ACC_ENUM);
  45. ZEND_ASSERT(zobj->ce->enum_backing_type != IS_UNDEF);
  46. return OBJ_PROP_NUM(zobj, 1);
  47. }
  48. END_EXTERN_C()
  49. #endif /* ZEND_ENUM_H */