Skip to content

Commit 53eef71

Browse files
committed
Use inline functions instead of macros in zend_API.h
1 parent 2aceb0b commit 53eef71

File tree

1 file changed

+76
-27
lines changed

1 file changed

+76
-27
lines changed

Zend/zend_API.h

Lines changed: 76 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -379,8 +379,9 @@ ZEND_API void zend_class_implements(zend_class_entry *class_entry, int num_inter
379379

380380
ZEND_API zend_result zend_register_class_alias_ex(const char *name, size_t name_len, zend_class_entry *ce, bool persistent);
381381

382-
#define zend_register_class_alias(name, ce) \
383-
zend_register_class_alias_ex(name, sizeof(name)-1, ce, 1)
382+
static inline zend_result zend_register_class_alias(const char *name, zend_class_entry *ce) {
383+
return zend_register_class_alias_ex(name, strlen(name), ce, 1);
384+
}
384385
#define zend_register_ns_class_alias(ns, name, ce) \
385386
zend_register_class_alias_ex(ZEND_NS_NAME(ns, name), sizeof(ZEND_NS_NAME(ns, name))-1, ce, 1)
386387

@@ -515,18 +516,42 @@ ZEND_API void add_assoc_object_ex(zval *arg, const char *key, size_t key_len, ze
515516
ZEND_API void add_assoc_reference_ex(zval *arg, const char *key, size_t key_len, zend_reference *ref);
516517
ZEND_API void add_assoc_zval_ex(zval *arg, const char *key, size_t key_len, zval *value);
517518

518-
#define add_assoc_long(__arg, __key, __n) add_assoc_long_ex(__arg, __key, strlen(__key), __n)
519-
#define add_assoc_null(__arg, __key) add_assoc_null_ex(__arg, __key, strlen(__key))
520-
#define add_assoc_bool(__arg, __key, __b) add_assoc_bool_ex(__arg, __key, strlen(__key), __b)
521-
#define add_assoc_resource(__arg, __key, __r) add_assoc_resource_ex(__arg, __key, strlen(__key), __r)
522-
#define add_assoc_double(__arg, __key, __d) add_assoc_double_ex(__arg, __key, strlen(__key), __d)
523-
#define add_assoc_str(__arg, __key, __str) add_assoc_str_ex(__arg, __key, strlen(__key), __str)
524-
#define add_assoc_string(__arg, __key, __str) add_assoc_string_ex(__arg, __key, strlen(__key), __str)
525-
#define add_assoc_stringl(__arg, __key, __str, __length) add_assoc_stringl_ex(__arg, __key, strlen(__key), __str, __length)
526-
#define add_assoc_array(__arg, __key, __arr) add_assoc_array_ex(__arg, __key, strlen(__key), __arr)
527-
#define add_assoc_object(__arg, __key, __obj) add_assoc_object_ex(__arg, __key, strlen(__key), __obj)
528-
#define add_assoc_reference(__arg, __key, __ref) add_assoc_object_ex(__arg, __key, strlen(__key), __ref)
529-
#define add_assoc_zval(__arg, __key, __value) add_assoc_zval_ex(__arg, __key, strlen(__key), __value)
519+
static inline void add_assoc_long(zval *arg, const char *key, zend_long n) {
520+
add_assoc_long_ex(arg, key, strlen(key), n);
521+
}
522+
static inline void add_assoc_null(zval *arg, const char *key) {
523+
add_assoc_null_ex(arg, key, strlen(key));
524+
}
525+
static inline void add_assoc_bool(zval *arg, const char *key, bool b) {
526+
add_assoc_bool_ex(arg, key, strlen(key), b);
527+
}
528+
static inline void add_assoc_resource(zval *arg, const char *key, zend_resource *r) {
529+
add_assoc_resource_ex(arg, key, strlen(key), r);
530+
}
531+
static inline void add_assoc_double(zval *arg, const char *key, double d) {
532+
add_assoc_double_ex(arg, key, strlen(key), d);
533+
}
534+
static inline void add_assoc_str(zval *arg, const char *key, zend_string *str) {
535+
add_assoc_str_ex(arg, key, strlen(key), str);
536+
}
537+
static inline void add_assoc_string(zval *arg, const char *key, const char *str) {
538+
add_assoc_string_ex(arg, key, strlen(key), str);
539+
}
540+
static inline void add_assoc_stringl(zval *arg, const char *key, const char *str, size_t length) {
541+
add_assoc_stringl_ex(arg, key, strlen(key), str, length);
542+
}
543+
static inline void add_assoc_array(zval *arg, const char *key, zend_array *arr) {
544+
add_assoc_array_ex(arg, key, strlen(key), arr);
545+
}
546+
static inline void add_assoc_object(zval *arg, const char *key, zend_object *obj) {
547+
add_assoc_object_ex(arg, key, strlen(key), obj);
548+
}
549+
static inline void add_assoc_reference(zval *arg, const char *key, zend_reference *ref) {
550+
add_assoc_reference_ex(arg, key, strlen(key), ref);
551+
}
552+
static inline void add_assoc_zval(zval *arg, const char *key, zval *value) {
553+
add_assoc_zval_ex(arg, key, strlen(key), value);
554+
}
530555

531556
ZEND_API void add_index_long(zval *arg, zend_ulong index, zend_long n);
532557
ZEND_API void add_index_null(zval *arg, zend_ulong index);
@@ -577,20 +602,44 @@ ZEND_API void add_property_object_ex(zval *arg, const char *key, size_t key_len,
577602
ZEND_API void add_property_reference_ex(zval *arg, const char *key, size_t key_len, zend_reference *ref);
578603
ZEND_API void add_property_zval_ex(zval *arg, const char *key, size_t key_len, zval *value);
579604

580-
#define add_property_long(__arg, __key, __n) add_property_long_ex(__arg, __key, strlen(__key), __n)
581-
#define add_property_null(__arg, __key) add_property_null_ex(__arg, __key, strlen(__key))
582-
#define add_property_bool(__arg, __key, __b) add_property_bool_ex(__arg, __key, strlen(__key), __b)
583-
#define add_property_resource(__arg, __key, __r) add_property_resource_ex(__arg, __key, strlen(__key), __r)
584-
#define add_property_double(__arg, __key, __d) add_property_double_ex(__arg, __key, strlen(__key), __d)
585-
#define add_property_str(__arg, __key, __str) add_property_str_ex(__arg, __key, strlen(__key), __str)
586-
#define add_property_string(__arg, __key, __str) add_property_string_ex(__arg, __key, strlen(__key), __str)
587-
#define add_property_stringl(__arg, __key, __str, __length) add_property_stringl_ex(__arg, __key, strlen(__key), __str, __length)
588-
#define add_property_array(__arg, __key, __arr) add_property_array_ex(__arg, __key, strlen(__key), __arr)
589-
#define add_property_object(__arg, __key, __obj) add_property_object_ex(__arg, __key, strlen(__key), __obj)
590-
#define add_property_reference(__arg, __key, __ref) add_property_reference_ex(__arg, __key, strlen(__key), __ref)
591-
#define add_property_zval(__arg, __key, __value) add_property_zval_ex(__arg, __key, strlen(__key), __value)
592-
605+
static inline void add_property_long(zval *arg, const char *key, zend_long n) {
606+
add_property_long_ex(arg, key, strlen(key), n);
607+
}
608+
static inline void add_property_null(zval *arg, const char *key) {
609+
add_property_null_ex(arg, key, strlen(key));
610+
}
611+
static inline void add_property_bool(zval *arg, const char *key, bool b) {
612+
add_property_bool_ex(arg, key, strlen(key), b);
613+
}
614+
static inline void add_property_resource(zval *arg, const char *key, zend_resource *r) {
615+
add_property_resource_ex(arg, key, strlen(key), r);
616+
}
617+
static inline void add_property_double(zval *arg, const char *key, double d) {
618+
add_property_double_ex(arg, key, strlen(key), d);
619+
}
620+
static inline void add_property_str(zval *arg, const char *key, zend_string *str) {
621+
add_property_str_ex(arg, key, strlen(key), str);
622+
}
623+
static inline void add_property_string(zval *arg, const char *key, const char *str) {
624+
add_property_string_ex(arg, key, strlen(key), str);
625+
}
626+
static inline void add_property_stringl(zval *arg, const char *key, const char *str, size_t length) {
627+
add_property_stringl_ex(arg, key, strlen(key), str, length);
628+
}
629+
static inline void add_property_array(zval *arg, const char *key, zend_array *arr) {
630+
add_property_array_ex(arg, key, strlen(key), arr);
631+
}
632+
static inline void add_property_object(zval *arg, const char *key, zend_object *obj) {
633+
add_property_object_ex(arg, key, strlen(key), obj);
634+
}
635+
static inline void add_property_reference(zval *arg, const char *key, zend_reference *ref) {
636+
add_property_reference_ex(arg, key, strlen(key), ref);
637+
}
638+
static inline void add_property_zval(zval *arg, const char *key, zval *value) {
639+
add_property_zval_ex(arg, key, strlen(key), value);
640+
}
593641

642+
// TODO Drop function_table argument?
594643
ZEND_API zend_result _call_user_function_impl(zval *object, zval *function_name, zval *retval_ptr, uint32_t param_count, zval params[], HashTable *named_params);
595644

596645
#define call_user_function(function_table, object, function_name, retval_ptr, param_count, params) \

0 commit comments

Comments
 (0)