Skip to content

Commit bd72699

Browse files
committed
Use inline functions instead of macros in zend_API.h
1 parent 5c693c7 commit bd72699

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
@@ -382,8 +382,9 @@ ZEND_API void zend_class_implements(zend_class_entry *class_entry, int num_inter
382382

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

385-
#define zend_register_class_alias(name, ce) \
386-
zend_register_class_alias_ex(name, sizeof(name)-1, ce, 1)
385+
static inline zend_result zend_register_class_alias(const char *name, zend_class_entry *ce) {
386+
return zend_register_class_alias_ex(name, strlen(name), ce, 1);
387+
}
387388
#define zend_register_ns_class_alias(ns, name, ce) \
388389
zend_register_class_alias_ex(ZEND_NS_NAME(ns, name), sizeof(ZEND_NS_NAME(ns, name))-1, ce, 1)
389390

@@ -540,18 +541,42 @@ ZEND_API void add_assoc_object_ex(zval *arg, const char *key, size_t key_len, ze
540541
ZEND_API void add_assoc_reference_ex(zval *arg, const char *key, size_t key_len, zend_reference *ref);
541542
ZEND_API void add_assoc_zval_ex(zval *arg, const char *key, size_t key_len, zval *value);
542543

543-
#define add_assoc_long(__arg, __key, __n) add_assoc_long_ex(__arg, __key, strlen(__key), __n)
544-
#define add_assoc_null(__arg, __key) add_assoc_null_ex(__arg, __key, strlen(__key))
545-
#define add_assoc_bool(__arg, __key, __b) add_assoc_bool_ex(__arg, __key, strlen(__key), __b)
546-
#define add_assoc_resource(__arg, __key, __r) add_assoc_resource_ex(__arg, __key, strlen(__key), __r)
547-
#define add_assoc_double(__arg, __key, __d) add_assoc_double_ex(__arg, __key, strlen(__key), __d)
548-
#define add_assoc_str(__arg, __key, __str) add_assoc_str_ex(__arg, __key, strlen(__key), __str)
549-
#define add_assoc_string(__arg, __key, __str) add_assoc_string_ex(__arg, __key, strlen(__key), __str)
550-
#define add_assoc_stringl(__arg, __key, __str, __length) add_assoc_stringl_ex(__arg, __key, strlen(__key), __str, __length)
551-
#define add_assoc_array(__arg, __key, __arr) add_assoc_array_ex(__arg, __key, strlen(__key), __arr)
552-
#define add_assoc_object(__arg, __key, __obj) add_assoc_object_ex(__arg, __key, strlen(__key), __obj)
553-
#define add_assoc_reference(__arg, __key, __ref) add_assoc_object_ex(__arg, __key, strlen(__key), __ref)
554-
#define add_assoc_zval(__arg, __key, __value) add_assoc_zval_ex(__arg, __key, strlen(__key), __value)
544+
static inline void add_assoc_long(zval *arg, const char *key, zend_long n) {
545+
add_assoc_long_ex(arg, key, strlen(key), n);
546+
}
547+
static inline void add_assoc_null(zval *arg, const char *key) {
548+
add_assoc_null_ex(arg, key, strlen(key));
549+
}
550+
static inline void add_assoc_bool(zval *arg, const char *key, bool b) {
551+
add_assoc_bool_ex(arg, key, strlen(key), b);
552+
}
553+
static inline void add_assoc_resource(zval *arg, const char *key, zend_resource *r) {
554+
add_assoc_resource_ex(arg, key, strlen(key), r);
555+
}
556+
static inline void add_assoc_double(zval *arg, const char *key, double d) {
557+
add_assoc_double_ex(arg, key, strlen(key), d);
558+
}
559+
static inline void add_assoc_str(zval *arg, const char *key, zend_string *str) {
560+
add_assoc_str_ex(arg, key, strlen(key), str);
561+
}
562+
static inline void add_assoc_string(zval *arg, const char *key, const char *str) {
563+
add_assoc_string_ex(arg, key, strlen(key), str);
564+
}
565+
static inline void add_assoc_stringl(zval *arg, const char *key, const char *str, size_t length) {
566+
add_assoc_stringl_ex(arg, key, strlen(key), str, length);
567+
}
568+
static inline void add_assoc_array(zval *arg, const char *key, zend_array *arr) {
569+
add_assoc_array_ex(arg, key, strlen(key), arr);
570+
}
571+
static inline void add_assoc_object(zval *arg, const char *key, zend_object *obj) {
572+
add_assoc_object_ex(arg, key, strlen(key), obj);
573+
}
574+
static inline void add_assoc_reference(zval *arg, const char *key, zend_reference *ref) {
575+
add_assoc_reference_ex(arg, key, strlen(key), ref);
576+
}
577+
static inline void add_assoc_zval(zval *arg, const char *key, zval *value) {
578+
add_assoc_zval_ex(arg, key, strlen(key), value);
579+
}
555580

556581
ZEND_API void add_index_long(zval *arg, zend_ulong index, zend_long n);
557582
ZEND_API void add_index_null(zval *arg, zend_ulong index);
@@ -602,20 +627,44 @@ ZEND_API void add_property_object_ex(zval *arg, const char *key, size_t key_len,
602627
ZEND_API void add_property_reference_ex(zval *arg, const char *key, size_t key_len, zend_reference *ref);
603628
ZEND_API void add_property_zval_ex(zval *arg, const char *key, size_t key_len, zval *value);
604629

605-
#define add_property_long(__arg, __key, __n) add_property_long_ex(__arg, __key, strlen(__key), __n)
606-
#define add_property_null(__arg, __key) add_property_null_ex(__arg, __key, strlen(__key))
607-
#define add_property_bool(__arg, __key, __b) add_property_bool_ex(__arg, __key, strlen(__key), __b)
608-
#define add_property_resource(__arg, __key, __r) add_property_resource_ex(__arg, __key, strlen(__key), __r)
609-
#define add_property_double(__arg, __key, __d) add_property_double_ex(__arg, __key, strlen(__key), __d)
610-
#define add_property_str(__arg, __key, __str) add_property_str_ex(__arg, __key, strlen(__key), __str)
611-
#define add_property_string(__arg, __key, __str) add_property_string_ex(__arg, __key, strlen(__key), __str)
612-
#define add_property_stringl(__arg, __key, __str, __length) add_property_stringl_ex(__arg, __key, strlen(__key), __str, __length)
613-
#define add_property_array(__arg, __key, __arr) add_property_array_ex(__arg, __key, strlen(__key), __arr)
614-
#define add_property_object(__arg, __key, __obj) add_property_object_ex(__arg, __key, strlen(__key), __obj)
615-
#define add_property_reference(__arg, __key, __ref) add_property_reference_ex(__arg, __key, strlen(__key), __ref)
616-
#define add_property_zval(__arg, __key, __value) add_property_zval_ex(__arg, __key, strlen(__key), __value)
617-
630+
static inline void add_property_long(zval *arg, const char *key, zend_long n) {
631+
add_property_long_ex(arg, key, strlen(key), n);
632+
}
633+
static inline void add_property_null(zval *arg, const char *key) {
634+
add_property_null_ex(arg, key, strlen(key));
635+
}
636+
static inline void add_property_bool(zval *arg, const char *key, bool b) {
637+
add_property_bool_ex(arg, key, strlen(key), b);
638+
}
639+
static inline void add_property_resource(zval *arg, const char *key, zend_resource *r) {
640+
add_property_resource_ex(arg, key, strlen(key), r);
641+
}
642+
static inline void add_property_double(zval *arg, const char *key, double d) {
643+
add_property_double_ex(arg, key, strlen(key), d);
644+
}
645+
static inline void add_property_str(zval *arg, const char *key, zend_string *str) {
646+
add_property_str_ex(arg, key, strlen(key), str);
647+
}
648+
static inline void add_property_string(zval *arg, const char *key, const char *str) {
649+
add_property_string_ex(arg, key, strlen(key), str);
650+
}
651+
static inline void add_property_stringl(zval *arg, const char *key, const char *str, size_t length) {
652+
add_property_stringl_ex(arg, key, strlen(key), str, length);
653+
}
654+
static inline void add_property_array(zval *arg, const char *key, zend_array *arr) {
655+
add_property_array_ex(arg, key, strlen(key), arr);
656+
}
657+
static inline void add_property_object(zval *arg, const char *key, zend_object *obj) {
658+
add_property_object_ex(arg, key, strlen(key), obj);
659+
}
660+
static inline void add_property_reference(zval *arg, const char *key, zend_reference *ref) {
661+
add_property_reference_ex(arg, key, strlen(key), ref);
662+
}
663+
static inline void add_property_zval(zval *arg, const char *key, zval *value) {
664+
add_property_zval_ex(arg, key, strlen(key), value);
665+
}
618666

667+
// TODO Drop function_table argument?
619668
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);
620669

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

0 commit comments

Comments
 (0)