File: psr_private.h

package info (click to toggle)
php-psr 1.2.0-9
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 548 kB
  • sloc: ansic: 1,485; pascal: 203; xml: 150; makefile: 2
file content (70 lines) | stat: -rw-r--r-- 2,864 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70

#define PHP_PSR_ABSTRACT_ME(p, c, f) PHP_ABSTRACT_ME(p ## c, f, PHP_PSR_ARGINFO(p, c, f))
#define PHP_PSR_ABSTRACT_ME_WITH_FLAGS(p, c, f, fl) ZEND_FENTRY(f, NULL, PHP_PSR_ARGINFO(p, c, f), fl)

static zend_always_inline zend_class_entry* php_psr_register_interface(
    const char* class_name,
    size_t class_name_len,
    const char* class_alias,
    size_t class_alias_len,
    zend_function_entry* methods

) {
    zend_class_entry ce;
    zend_class_entry *class_entry;
    INIT_CLASS_ENTRY_EX(ce, class_name, class_name_len, methods);
    class_entry = zend_register_internal_interface(&ce);
    zend_register_class_alias_ex(class_alias, class_alias_len, class_entry, 1);
    return class_entry;
}

#define PHP_PSR_REGISTER_INTERFACE_EX(class_name, methods, ce) do { \
        ce = php_psr_register_interface( \
            PHP_PSR_CLASS_NAMESPACE "\\" class_name, \
            sizeof(PHP_PSR_CLASS_NAMESPACE "\\" class_name)-1, \
            PHP_PSR_ALIAS_NAMESPACE "\\" class_name, \
            sizeof(PHP_PSR_ALIAS_NAMESPACE "\\" class_name)-1, \
            methods \
        ); \
    } while (0)

#define PHP_PSR_REGISTER_INTERFACE(psr_name, class_name) do { \
        PHP_PSR_REGISTER_INTERFACE_EX(#psr_name "\\" #class_name, Psr ## psr_name ## class_name ## _methods ,  Psr ## psr_name ## class_name ## _ce_ptr); \
    } while(0)

#define PHP_PSR_REGISTER_INTERFACE2(psr_name, ns_name, class_name) do { \
        PHP_PSR_REGISTER_INTERFACE_EX(#psr_name "\\" #ns_name "\\" #class_name, Psr ## psr_name ## ns_name ## class_name ## _methods ,  Psr ## psr_name ## ns_name ## class_name ## _ce_ptr); \
    } while(0)



static zend_always_inline zend_class_entry* php_psr_register_class(
    const char* class_name,
    size_t class_name_len,
    const char* class_alias,
    size_t class_alias_len,
    zend_function_entry* methods,
    zend_class_entry* parent_ce
) {
    zend_class_entry ce;
    zend_class_entry *class_entry;
    INIT_CLASS_ENTRY_EX(ce, class_name, class_name_len, methods);
    class_entry = zend_register_internal_class_ex(&ce, parent_ce);
    zend_register_class_alias_ex(class_alias, class_alias_len, class_entry, 1);
    return class_entry;
}

#define PHP_PSR_REGISTER_CLASS_EX(class_name, methods, ce, parent_ce) do { \
        ce = php_psr_register_class( \
            PHP_PSR_CLASS_NAMESPACE "\\" class_name, \
            sizeof(PHP_PSR_CLASS_NAMESPACE "\\" class_name)-1, \
            PHP_PSR_ALIAS_NAMESPACE "\\" class_name, \
            sizeof(PHP_PSR_ALIAS_NAMESPACE "\\" class_name)-1, \
            methods, \
            parent_ce \
        ); \
    } while (0)

#define PHP_PSR_REGISTER_CLASS(psr_name, class_name, parent_ce) do { \
        PHP_PSR_REGISTER_CLASS_EX(#psr_name "\\" #class_name, Psr ## psr_name ## class_name ## _methods ,  Psr ## psr_name ## class_name ## _ce_ptr, parent_ce); \
    } while(0)