1 /*
2    +----------------------------------------------------------------------+
3    | Copyright (c) The PHP Group                                          |
4    +----------------------------------------------------------------------+
5    | This source file is subject to version 3.01 of the PHP license,      |
6    | that is bundled with this package in the file LICENSE, and is        |
7    | available through the world-wide-web at the following url:           |
8    | https://www.php.net/license/3_01.txt                                 |
9    | If you did not receive a copy of the PHP license and are unable to   |
10    | obtain it through the world-wide-web, please send a note to          |
11    | license@php.net so we can mail you a copy immediately.               |
12    +----------------------------------------------------------------------+
13    | Author:  Sascha Schumann <sascha@schumann.cx>                        |
14    +----------------------------------------------------------------------+
15 */
16 
17 #ifndef PHP_INCOMPLETE_CLASS_H
18 #define PHP_INCOMPLETE_CLASS_H
19 
20 #include "ext/standard/basic_functions.h"
21 
22 extern PHPAPI zend_class_entry *php_ce_incomplete_class;
23 
24 #define PHP_IC_ENTRY php_ce_incomplete_class
25 
26 #define PHP_SET_CLASS_ATTRIBUTES(struc) \
27 	/* OBJECTS_FIXME: Fix for new object model */	\
28 	if (Z_OBJCE_P(struc) == php_ce_incomplete_class) {	\
29 		class_name = php_lookup_class_name(Z_OBJ_P(struc)); \
30 		if (!class_name) { \
31 			class_name = zend_string_init(INCOMPLETE_CLASS, sizeof(INCOMPLETE_CLASS) - 1, 0); \
32 		} \
33 		incomplete_class = 1; \
34 	} else { \
35 		class_name = zend_string_copy(Z_OBJCE_P(struc)->name); \
36 	}
37 
38 #define PHP_CLEANUP_CLASS_ATTRIBUTES()	\
39 	zend_string_release_ex(class_name, 0)
40 
41 #define PHP_CLASS_ATTRIBUTES											\
42 	zend_string *class_name;											\
43 	bool incomplete_class ZEND_ATTRIBUTE_UNUSED = 0
44 
45 #define INCOMPLETE_CLASS "__PHP_Incomplete_Class"
46 #define MAGIC_MEMBER "__PHP_Incomplete_Class_Name"
47 
48 #ifdef __cplusplus
49 extern "C" {
50 #endif
51 
52 PHPAPI void php_register_incomplete_class_handlers(void);
53 PHPAPI zend_string *php_lookup_class_name(zend_object *object);
54 PHPAPI void php_store_class_name(zval *object, zend_string *name);
55 
56 #ifdef __cplusplus
57 };
58 #endif
59 
60 #endif
61