From 13106eebea8710d9c46ed022f149bd74200e6adc Mon Sep 17 00:00:00 2001 From: Arnaud Le Blanc Date: Fri, 25 Oct 2024 17:24:58 +0200 Subject: [PATCH] Cleanup php 7 compatibility code (#564) --- kafka_consumer.c | 8 ++--- kafka_error_exception.c | 32 ++++++++--------- message.c | 24 ++++++------- metadata.c | 14 ++++---- metadata_broker.c | 6 ++-- metadata_collection.c | 10 +++--- metadata_collection.h | 2 +- metadata_partition.c | 10 +++--- metadata_topic.c | 10 +++--- php_rdkafka_priv.h | 80 +---------------------------------------- topic_partition.c | 6 ++-- 11 files changed, 62 insertions(+), 140 deletions(-) diff --git a/kafka_consumer.c b/kafka_consumer.c index aa326738..a3f57584 100644 --- a/kafka_consumer.c +++ b/kafka_consumer.c @@ -446,25 +446,25 @@ static void consumer_commit(int async, INTERNAL_FUNCTION_PARAMETERS) /* {{{ */ zval *zoffset; rd_kafka_topic_partition_t *rktpar; - zerr = rdkafka_read_property(NULL, Z_RDKAFKA_PROP_OBJ(zarg), ZEND_STRL("err"), 0); + zerr = rdkafka_read_property(NULL, Z_OBJ_P(zarg), ZEND_STRL("err"), 0); if (zerr && Z_TYPE_P(zerr) != IS_NULL && (Z_TYPE_P(zerr) != IS_LONG || Z_LVAL_P(zerr) != RD_KAFKA_RESP_ERR_NO_ERROR)) { zend_throw_exception(ce_kafka_exception, "Invalid argument: Specified Message has an error", RD_KAFKA_RESP_ERR__INVALID_ARG); return; } - ztopic = rdkafka_read_property(NULL, Z_RDKAFKA_PROP_OBJ(zarg), ZEND_STRL("topic_name"), 0); + ztopic = rdkafka_read_property(NULL, Z_OBJ_P(zarg), ZEND_STRL("topic_name"), 0); if (!ztopic || Z_TYPE_P(ztopic) != IS_STRING) { zend_throw_exception(ce_kafka_exception, "Invalid argument: Specified Message's topic_name is not a string", RD_KAFKA_RESP_ERR__INVALID_ARG); return; } - zpartition = rdkafka_read_property(NULL, Z_RDKAFKA_PROP_OBJ(zarg), ZEND_STRL("partition"), 0); + zpartition = rdkafka_read_property(NULL, Z_OBJ_P(zarg), ZEND_STRL("partition"), 0); if (!zpartition || Z_TYPE_P(zpartition) != IS_LONG) { zend_throw_exception(ce_kafka_exception, "Invalid argument: Specified Message's partition is not an int", RD_KAFKA_RESP_ERR__INVALID_ARG); return; } - zoffset = rdkafka_read_property(NULL, Z_RDKAFKA_PROP_OBJ(zarg), ZEND_STRL("offset"), 0); + zoffset = rdkafka_read_property(NULL, Z_OBJ_P(zarg), ZEND_STRL("offset"), 0); if (!zoffset || Z_TYPE_P(zoffset) != IS_LONG) { zend_throw_exception(ce_kafka_exception, "Invalid argument: Specified Message's offset is not an int", RD_KAFKA_RESP_ERR__INVALID_ARG); return; diff --git a/kafka_error_exception.c b/kafka_error_exception.c index 005d11b6..ce00d821 100644 --- a/kafka_error_exception.c +++ b/kafka_error_exception.c @@ -36,13 +36,13 @@ void create_kafka_error(zval *return_value, const rd_kafka_error_t *error) /* {{ char message[1024]; snprintf(message, sizeof(message), "%s (RD_KAFKA_RESP_ERR_%s)", rd_kafka_error_string(error), rd_kafka_error_name(error)); - zend_update_property_string(ce_kafka_error, Z_RDKAFKA_PROP_OBJ(return_value), ZEND_STRL("message"), message); + zend_update_property_string(ce_kafka_error, Z_OBJ_P(return_value), ZEND_STRL("message"), message); - zend_update_property_long(ce_kafka_error, Z_RDKAFKA_PROP_OBJ(return_value), ZEND_STRL("code"), rd_kafka_error_code(error)); - zend_update_property_string(ce_kafka_error, Z_RDKAFKA_PROP_OBJ(return_value), ZEND_STRL("error_string"), rd_kafka_error_string(error)); - zend_update_property_bool(ce_kafka_error, Z_RDKAFKA_PROP_OBJ(return_value), ZEND_STRL("isFatal"), rd_kafka_error_is_fatal(error)); - zend_update_property_bool(ce_kafka_error, Z_RDKAFKA_PROP_OBJ(return_value), ZEND_STRL("isRetriable"), rd_kafka_error_is_retriable(error)); - zend_update_property_bool(ce_kafka_error, Z_RDKAFKA_PROP_OBJ(return_value), ZEND_STRL("transactionRequiresAbort"), rd_kafka_error_txn_requires_abort(error)); + zend_update_property_long(ce_kafka_error, Z_OBJ_P(return_value), ZEND_STRL("code"), rd_kafka_error_code(error)); + zend_update_property_string(ce_kafka_error, Z_OBJ_P(return_value), ZEND_STRL("error_string"), rd_kafka_error_string(error)); + zend_update_property_bool(ce_kafka_error, Z_OBJ_P(return_value), ZEND_STRL("isFatal"), rd_kafka_error_is_fatal(error)); + zend_update_property_bool(ce_kafka_error, Z_OBJ_P(return_value), ZEND_STRL("isRetriable"), rd_kafka_error_is_retriable(error)); + zend_update_property_bool(ce_kafka_error, Z_OBJ_P(return_value), ZEND_STRL("transactionRequiresAbort"), rd_kafka_error_txn_requires_abort(error)); Z_ADDREF_P(return_value); } @@ -60,12 +60,12 @@ PHP_METHOD(RdKafka_KafkaErrorException, __construct) return; } - zend_update_property_string(ce_kafka_error, Z_RDKAFKA_PROP_OBJ(getThis()), ZEND_STRL("message"), message); - zend_update_property_long(ce_kafka_error, Z_RDKAFKA_PROP_OBJ(getThis()), ZEND_STRL("code"), code); - zend_update_property_string(ce_kafka_error, Z_RDKAFKA_PROP_OBJ(getThis()), ZEND_STRL("error_string"), error_string); - zend_update_property_bool(ce_kafka_error, Z_RDKAFKA_PROP_OBJ(getThis()), ZEND_STRL("isFatal"), isFatal); - zend_update_property_bool(ce_kafka_error, Z_RDKAFKA_PROP_OBJ(getThis()), ZEND_STRL("isRetriable"), isRetriable); - zend_update_property_bool(ce_kafka_error, Z_RDKAFKA_PROP_OBJ(getThis()), ZEND_STRL("transactionRequiresAbort"), transactionRequiresAbort); + zend_update_property_string(ce_kafka_error, Z_OBJ_P(getThis()), ZEND_STRL("message"), message); + zend_update_property_long(ce_kafka_error, Z_OBJ_P(getThis()), ZEND_STRL("code"), code); + zend_update_property_string(ce_kafka_error, Z_OBJ_P(getThis()), ZEND_STRL("error_string"), error_string); + zend_update_property_bool(ce_kafka_error, Z_OBJ_P(getThis()), ZEND_STRL("isFatal"), isFatal); + zend_update_property_bool(ce_kafka_error, Z_OBJ_P(getThis()), ZEND_STRL("isRetriable"), isRetriable); + zend_update_property_bool(ce_kafka_error, Z_OBJ_P(getThis()), ZEND_STRL("transactionRequiresAbort"), transactionRequiresAbort); } /* }}} */ @@ -79,7 +79,7 @@ PHP_METHOD(RdKafka_KafkaErrorException, getErrorString) return; } - res = rdkafka_read_property(ce_kafka_error, Z_RDKAFKA_PROP_OBJ(getThis()), ZEND_STRL("error_string"), 0); + res = rdkafka_read_property(ce_kafka_error, Z_OBJ_P(getThis()), ZEND_STRL("error_string"), 0); if (!res || Z_TYPE_P(res) != IS_STRING) { return; @@ -101,7 +101,7 @@ PHP_METHOD(RdKafka_KafkaErrorException, isFatal) return; } - res = rdkafka_read_property(ce_kafka_error, Z_RDKAFKA_PROP_OBJ(getThis()), ZEND_STRL("isFatal"), 0); + res = rdkafka_read_property(ce_kafka_error, Z_OBJ_P(getThis()), ZEND_STRL("isFatal"), 0); if (!res || (Z_TYPE_P(res) != IS_TRUE && Z_TYPE_P(res) != IS_FALSE)) { return; @@ -122,7 +122,7 @@ PHP_METHOD(RdKafka_KafkaErrorException, isRetriable) return; } - res = rdkafka_read_property(ce_kafka_error, Z_RDKAFKA_PROP_OBJ(getThis()), ZEND_STRL("isRetriable"), 0); + res = rdkafka_read_property(ce_kafka_error, Z_OBJ_P(getThis()), ZEND_STRL("isRetriable"), 0); if (!res || (Z_TYPE_P(res) != IS_TRUE && Z_TYPE_P(res) != IS_FALSE)) { return; @@ -143,7 +143,7 @@ PHP_METHOD(RdKafka_KafkaErrorException, transactionRequiresAbort) return; } - res = rdkafka_read_property(ce_kafka_error, Z_RDKAFKA_PROP_OBJ(getThis()), ZEND_STRL("transactionRequiresAbort"), 0); + res = rdkafka_read_property(ce_kafka_error, Z_OBJ_P(getThis()), ZEND_STRL("transactionRequiresAbort"), 0); if (!res || (Z_TYPE_P(res) != IS_TRUE && Z_TYPE_P(res) != IS_FALSE)) { return; diff --git a/message.c b/message.c index b9278ae5..4569e956 100644 --- a/message.c +++ b/message.c @@ -50,21 +50,21 @@ void kafka_message_new(zval *return_value, const rd_kafka_message_t *message, ze size_t header_size = 0; size_t i; - zend_update_property_long(NULL, Z_RDKAFKA_PROP_OBJ(return_value), ZEND_STRL("err"), message->err); + zend_update_property_long(NULL, Z_OBJ_P(return_value), ZEND_STRL("err"), message->err); if (message->rkt) { - zend_update_property_string(NULL, Z_RDKAFKA_PROP_OBJ(return_value), ZEND_STRL("topic_name"), rd_kafka_topic_name(message->rkt)); + zend_update_property_string(NULL, Z_OBJ_P(return_value), ZEND_STRL("topic_name"), rd_kafka_topic_name(message->rkt)); } - zend_update_property_long(NULL, Z_RDKAFKA_PROP_OBJ(return_value), ZEND_STRL("partition"), message->partition); + zend_update_property_long(NULL, Z_OBJ_P(return_value), ZEND_STRL("partition"), message->partition); if (message->payload) { - zend_update_property_long(NULL, Z_RDKAFKA_PROP_OBJ(return_value), ZEND_STRL("timestamp"), timestamp); - zend_update_property_stringl(NULL, Z_RDKAFKA_PROP_OBJ(return_value), ZEND_STRL("payload"), message->payload, message->len); - zend_update_property_long(NULL, Z_RDKAFKA_PROP_OBJ(return_value), ZEND_STRL("len"), message->len); + zend_update_property_long(NULL, Z_OBJ_P(return_value), ZEND_STRL("timestamp"), timestamp); + zend_update_property_stringl(NULL, Z_OBJ_P(return_value), ZEND_STRL("payload"), message->payload, message->len); + zend_update_property_long(NULL, Z_OBJ_P(return_value), ZEND_STRL("len"), message->len); } if (message->key) { - zend_update_property_stringl(NULL, Z_RDKAFKA_PROP_OBJ(return_value), ZEND_STRL("key"), message->key, message->key_len); + zend_update_property_stringl(NULL, Z_OBJ_P(return_value), ZEND_STRL("key"), message->key, message->key_len); } - zend_update_property_long(NULL, Z_RDKAFKA_PROP_OBJ(return_value), ZEND_STRL("offset"), message->offset); + zend_update_property_long(NULL, Z_OBJ_P(return_value), ZEND_STRL("offset"), message->offset); array_init(&headers_array); if (message->err == RD_KAFKA_RESP_ERR_NO_ERROR) { @@ -79,11 +79,11 @@ void kafka_message_new(zval *return_value, const rd_kafka_message_t *message, ze } } } - zend_update_property(NULL, Z_RDKAFKA_PROP_OBJ(return_value), ZEND_STRL("headers"), &headers_array); + zend_update_property(NULL, Z_OBJ_P(return_value), ZEND_STRL("headers"), &headers_array); zval_ptr_dtor(&headers_array); if (msg_opaque != NULL) { - zend_update_property_str(NULL, Z_RDKAFKA_PROP_OBJ(return_value), ZEND_STRL("opaque"), msg_opaque); + zend_update_property_str(NULL, Z_OBJ_P(return_value), ZEND_STRL("opaque"), msg_opaque); } } @@ -116,7 +116,7 @@ PHP_METHOD(RdKafka_Message, errstr) return; } - zerr = rdkafka_read_property(NULL, Z_RDKAFKA_PROP_OBJ(getThis()), ZEND_STRL("err"), 0); + zerr = rdkafka_read_property(NULL, Z_OBJ_P(getThis()), ZEND_STRL("err"), 0); if (!zerr || Z_TYPE_P(zerr) != IS_LONG) { return; @@ -128,7 +128,7 @@ PHP_METHOD(RdKafka_Message, errstr) RETURN_STRING(errstr); } - zpayload = rdkafka_read_property(NULL, Z_RDKAFKA_PROP_OBJ(getThis()), ZEND_STRL("payload"), 0); + zpayload = rdkafka_read_property(NULL, Z_OBJ_P(getThis()), ZEND_STRL("payload"), 0); if (zpayload && Z_TYPE_P(zpayload) == IS_STRING) { RETURN_ZVAL(zpayload, 1, 0); diff --git a/metadata.c b/metadata.c index 62c42522..98d019f8 100644 --- a/metadata.c +++ b/metadata.c @@ -36,17 +36,17 @@ typedef struct _object_intern { zend_object std; } object_intern; -static HashTable *get_debug_info(Z_RDKAFKA_OBJ *object, int *is_temp); +static HashTable *get_debug_info(zend_object *object, int *is_temp); static zend_class_entry * ce; static zend_object_handlers handlers; -static void brokers_collection(zval *return_value, Z_RDKAFKA_OBJ *parent, object_intern *intern) { /* {{{ */ +static void brokers_collection(zval *return_value, zend_object *parent, object_intern *intern) { /* {{{ */ kafka_metadata_collection_init(return_value, parent, intern->metadata->brokers, intern->metadata->broker_cnt, sizeof(*intern->metadata->brokers), kafka_metadata_broker_ctor); } /* }}} */ -static void topics_collection(zval *return_value, Z_RDKAFKA_OBJ *parent, object_intern *intern) { /* {{{ */ +static void topics_collection(zval *return_value, zend_object *parent, object_intern *intern) { /* {{{ */ kafka_metadata_collection_init(return_value, parent, intern->metadata->topics, intern->metadata->topic_cnt, sizeof(*intern->metadata->topics), kafka_metadata_topic_ctor); } /* }}} */ @@ -91,7 +91,7 @@ static object_intern * get_object(zval *zmetadata) return ometadata; } -static HashTable *get_debug_info(Z_RDKAFKA_OBJ *object, int *is_temp) /* {{{ */ +static HashTable *get_debug_info(zend_object *object, int *is_temp) /* {{{ */ { zval ary; object_intern *intern; @@ -102,7 +102,7 @@ static HashTable *get_debug_info(Z_RDKAFKA_OBJ *object, int *is_temp) /* {{{ */ array_init(&ary); - intern = rdkafka_get_debug_object(object_intern, object); + intern = php_kafka_from_obj(object_intern, object); if (!intern || !intern->metadata) { return Z_ARRVAL(ary); } @@ -175,7 +175,7 @@ PHP_METHOD(RdKafka_Metadata, getBrokers) return; } - brokers_collection(return_value, Z_RDKAFKA_PROP_OBJ(getThis()), intern); + brokers_collection(return_value, Z_OBJ_P(getThis()), intern); } /* }}} */ @@ -194,7 +194,7 @@ PHP_METHOD(RdKafka_Metadata, getTopics) return; } - topics_collection(return_value, Z_RDKAFKA_PROP_OBJ(getThis()), intern); + topics_collection(return_value, Z_OBJ_P(getThis()), intern); } /* }}} */ diff --git a/metadata_broker.c b/metadata_broker.c index 93c2def8..1925d76b 100644 --- a/metadata_broker.c +++ b/metadata_broker.c @@ -35,7 +35,7 @@ typedef struct _object_intern { zend_object std; } object_intern; -static HashTable *get_debug_info(Z_RDKAFKA_OBJ *object, int *is_temp); +static HashTable *get_debug_info(zend_object *object, int *is_temp); static zend_class_entry * ce; static zend_object_handlers handlers; @@ -80,7 +80,7 @@ static object_intern * get_object(zval *zmt) return omt; } -static HashTable *get_debug_info(Z_RDKAFKA_OBJ *object, int *is_temp) /* {{{ */ +static HashTable *get_debug_info(zend_object *object, int *is_temp) /* {{{ */ { zval ary; object_intern *intern; @@ -89,7 +89,7 @@ static HashTable *get_debug_info(Z_RDKAFKA_OBJ *object, int *is_temp) /* {{{ */ array_init(&ary); - intern = rdkafka_get_debug_object(object_intern, object); + intern = php_kafka_from_obj(object_intern, object); if (!intern || !intern->metadata_broker) { return Z_ARRVAL(ary); } diff --git a/metadata_collection.c b/metadata_collection.c index 67be479d..fc8004d7 100644 --- a/metadata_collection.c +++ b/metadata_collection.c @@ -40,7 +40,7 @@ typedef struct _object_intern { zend_object std; } object_intern; -static HashTable *get_debug_info(Z_RDKAFKA_OBJ *object, int *is_temp); +static HashTable *get_debug_info(zend_object *object, int *is_temp); static zend_class_entry *ce; static zend_object_handlers handlers; @@ -85,7 +85,7 @@ static object_intern * get_object(zval *zmti) return omti; } -static HashTable *get_debug_info(Z_RDKAFKA_OBJ *object, int *is_temp) /* {{{ */ +static HashTable *get_debug_info(zend_object *object, int *is_temp) /* {{{ */ { zval ary; object_intern *intern; @@ -96,7 +96,7 @@ static HashTable *get_debug_info(Z_RDKAFKA_OBJ *object, int *is_temp) /* {{{ */ array_init(&ary); - intern = rdkafka_get_debug_object(object_intern, object); + intern = php_kafka_from_obj(object_intern, object); if (!intern || !intern->items) { return Z_ARRVAL(ary); } @@ -246,7 +246,7 @@ void kafka_metadata_collection_minit(INIT_FUNC_ARGS) handlers.offset = XtOffsetOf(object_intern, std); } -void kafka_metadata_collection_init(zval *return_value, Z_RDKAFKA_OBJ *zmetadata, const void * items, size_t item_cnt, size_t item_size, kafka_metadata_collection_ctor_t ctor) +void kafka_metadata_collection_init(zval *return_value, zend_object *zmetadata, const void * items, size_t item_cnt, size_t item_size, kafka_metadata_collection_ctor_t ctor) { object_intern *intern; @@ -259,7 +259,7 @@ void kafka_metadata_collection_init(zval *return_value, Z_RDKAFKA_OBJ *zmetadata return; } - Z_RDKAFKA_OBJ_COPY(&intern->zmetadata, zmetadata); + ZVAL_OBJ_COPY(&intern->zmetadata, zmetadata); intern->items = items; intern->item_cnt = item_cnt; intern->item_size = item_size; diff --git a/metadata_collection.h b/metadata_collection.h index fff2fd6e..0769e4d8 100644 --- a/metadata_collection.h +++ b/metadata_collection.h @@ -19,4 +19,4 @@ typedef void (*kafka_metadata_collection_ctor_t)(zval *renurn_value, zval *zmetadata, const void *object); void kafka_metadata_collection_minit(INIT_FUNC_ARGS); -void kafka_metadata_collection_init(zval *return_value, Z_RDKAFKA_OBJ *zmetadata, const void * items, size_t item_cnt, size_t item_size, kafka_metadata_collection_ctor_t ctor); +void kafka_metadata_collection_init(zval *return_value, zend_object *zmetadata, const void * items, size_t item_cnt, size_t item_size, kafka_metadata_collection_ctor_t ctor); diff --git a/metadata_partition.c b/metadata_partition.c index 9a66217c..0c6c16ed 100644 --- a/metadata_partition.c +++ b/metadata_partition.c @@ -36,7 +36,7 @@ typedef struct _object_intern { zend_object std; } object_intern; -static HashTable *get_debug_info(Z_RDKAFKA_OBJ *object, int *is_temp); +static HashTable *get_debug_info(zend_object *object, int *is_temp); static zend_class_entry * ce; static zend_object_handlers handlers; @@ -81,7 +81,7 @@ static object_intern * get_object(zval *zmt) return omt; } -static HashTable *get_debug_info(Z_RDKAFKA_OBJ *object, int *is_temp) /* {{{ */ +static HashTable *get_debug_info(zend_object *object, int *is_temp) /* {{{ */ { zval ary; object_intern *intern; @@ -90,7 +90,7 @@ static HashTable *get_debug_info(Z_RDKAFKA_OBJ *object, int *is_temp) /* {{{ */ array_init(&ary); - intern = rdkafka_get_debug_object(object_intern, object); + intern = php_kafka_from_obj(object_intern, object); if (!intern || !intern->metadata_partition) { return Z_ARRVAL(ary); } @@ -181,7 +181,7 @@ PHP_METHOD(RdKafka_Metadata_Partition, getReplicas) return; } - kafka_metadata_collection_init(return_value, Z_RDKAFKA_PROP_OBJ(getThis()), intern->metadata_partition->replicas, intern->metadata_partition->replica_cnt, sizeof(*intern->metadata_partition->replicas), int32_ctor); + kafka_metadata_collection_init(return_value, Z_OBJ_P(getThis()), intern->metadata_partition->replicas, intern->metadata_partition->replica_cnt, sizeof(*intern->metadata_partition->replicas), int32_ctor); } /* }}} */ @@ -200,7 +200,7 @@ PHP_METHOD(RdKafka_Metadata_Partition, getIsrs) return; } - kafka_metadata_collection_init(return_value, Z_RDKAFKA_PROP_OBJ(getThis()), intern->metadata_partition->isrs, intern->metadata_partition->isr_cnt, sizeof(*intern->metadata_partition->isrs), int32_ctor); + kafka_metadata_collection_init(return_value, Z_OBJ_P(getThis()), intern->metadata_partition->isrs, intern->metadata_partition->isr_cnt, sizeof(*intern->metadata_partition->isrs), int32_ctor); } /* }}} */ diff --git a/metadata_topic.c b/metadata_topic.c index acd7fd22..4a4e8c75 100644 --- a/metadata_topic.c +++ b/metadata_topic.c @@ -37,12 +37,12 @@ typedef struct _object_intern { zend_object std; } object_intern; -static HashTable *get_debug_info(Z_RDKAFKA_OBJ *object, int *is_temp); +static HashTable *get_debug_info(zend_object *object, int *is_temp); static zend_class_entry * ce; static zend_object_handlers handlers; -static void partitions_collection(zval *return_value, Z_RDKAFKA_OBJ *parent, object_intern *intern) { /* {{{ */ +static void partitions_collection(zval *return_value, zend_object *parent, object_intern *intern) { /* {{{ */ kafka_metadata_collection_init(return_value, parent, intern->metadata_topic->partitions, intern->metadata_topic->partition_cnt, sizeof(*intern->metadata_topic->partitions), kafka_metadata_partition_ctor); } /* }}} */ @@ -87,7 +87,7 @@ static object_intern * get_object(zval *zmt) return omt; } -static HashTable *get_debug_info(Z_RDKAFKA_OBJ *object, int *is_temp) /* {{{ */ +static HashTable *get_debug_info(zend_object *object, int *is_temp) /* {{{ */ { zval ary; object_intern *intern; @@ -97,7 +97,7 @@ static HashTable *get_debug_info(Z_RDKAFKA_OBJ *object, int *is_temp) /* {{{ */ array_init(&ary); - intern = rdkafka_get_debug_object(object_intern, object); + intern = php_kafka_from_obj(object_intern, object); if (!intern || !intern->metadata_topic) { return Z_ARRVAL(ary); } @@ -168,7 +168,7 @@ PHP_METHOD(RdKafka_Metadata_Topic, getPartitions) return; } - partitions_collection(return_value, Z_RDKAFKA_PROP_OBJ(getThis()), intern); + partitions_collection(return_value, Z_OBJ_P(getThis()), intern); } /* }}} */ diff --git a/php_rdkafka_priv.h b/php_rdkafka_priv.h index ee6b440e..0b4ac06e 100644 --- a/php_rdkafka_priv.h +++ b/php_rdkafka_priv.h @@ -19,84 +19,6 @@ #ifndef PHP_RDKAFKA_PRIV_H #define PHP_RDKAFKA_PRIV_H -#ifndef Z_PARAM_STRING_OR_NULL -#define Z_PARAM_STRING_OR_NULL(dest, dest_len) \ - Z_PARAM_STRING_EX(dest, dest_len, 1, 0) -#endif - -#ifndef Z_PARAM_STR_OR_NULL -#define Z_PARAM_STR_OR_NULL(dest) \ - Z_PARAM_STR_EX(dest, 1, 0) -#endif - -#ifndef Z_PARAM_ARRAY_HT_OR_NULL -#define Z_PARAM_ARRAY_HT_OR_NULL(dest) \ - Z_PARAM_ARRAY_HT_EX(dest, 1, 0) -#endif - -#ifndef Z_PARAM_LONG_OR_NULL -#define Z_PARAM_LONG_OR_NULL(dest, is_null) \ - Z_PARAM_LONG_EX(dest, is_null, 1, 0) -#endif - -#ifndef ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_OBJ_INFO_EX -#define ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_OBJ_INFO_EX(name, return_reference, required_num_args, type, allow_null) \ - ZEND_BEGIN_ARG_INFO_EX(name, 0, return_reference, required_num_args) -#endif - -#ifndef ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX -#define ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(name, return_reference, required_num_args, type, allow_null) \ - ZEND_BEGIN_ARG_INFO_EX(name, 0, return_reference, required_num_args) -#endif - -#if PHP_MAJOR_VERSION >= 8 - -#define Z_RDKAFKA_OBJ zend_object - -#define Z_RDKAFKA_OBJ_COPY(z, o) ZVAL_OBJ_COPY(z, o) - -#define Z_RDKAFKA_PROP_OBJ(object) Z_OBJ_P(object) - -#define rdkafka_get_debug_object(type, object) php_kafka_from_obj(type, object) - -#else // PHP 7 - -#define Z_RDKAFKA_OBJ zval - -#define Z_RDKAFKA_OBJ_COPY(z, o) ZVAL_ZVAL(z, o, 1, 0) - -#define Z_RDKAFKA_PROP_OBJ(object) object - -#define rdkafka_get_debug_object(type, object) php_kafka_from_obj(type, Z_OBJ_P(object)) - -#if PHP_MINOR_VERSION < 3 -/* Allocates object type and zeros it, but not the properties. - * Properties MUST be initialized using object_properties_init(). */ -static zend_always_inline void *zend_object_alloc(size_t obj_size, zend_class_entry *ce) { - void *obj = emalloc(obj_size + zend_object_properties_size(ce)); - /* Subtraction of sizeof(zval) is necessary, because zend_object_properties_size() may be - * -sizeof(zval), if the object has no properties. */ - memset(obj, 0, obj_size - sizeof(zval)); - return obj; -} - -static zend_always_inline zend_string *zval_get_tmp_string(zval *op, zend_string **tmp) { - if (EXPECTED(Z_TYPE_P(op) == IS_STRING)) { - *tmp = NULL; - return Z_STR_P(op); - } else { - return *tmp = _zval_get_string_func(op); - } -} -static zend_always_inline void zend_tmp_string_release(zend_string *tmp) { - if (UNEXPECTED(tmp)) { - zend_string_release(tmp); - } -} -#endif // PHP_MINOR_VERSION < 3 - -#endif // PHP 7 - #define Z_RDKAFKA_P(php_kafka_type, zobject) php_kafka_from_obj(php_kafka_type, Z_OBJ_P(zobject)) #define php_kafka_from_obj(php_kafka_type, object) \ @@ -125,7 +47,7 @@ static inline void rdkafka_call_function(zend_fcall_info *fci, zend_fcall_info_c } } -static inline zval *rdkafka_read_property(zend_class_entry *scope, Z_RDKAFKA_OBJ *object, const char *name, size_t name_length, zend_bool silent) +static inline zval *rdkafka_read_property(zend_class_entry *scope, zend_object *object, const char *name, size_t name_length, zend_bool silent) { zval rv; return zend_read_property(scope, object, name, name_length, silent, &rv); diff --git a/topic_partition.c b/topic_partition.c index c4f7c9ab..fa7a1c22 100644 --- a/topic_partition.c +++ b/topic_partition.c @@ -33,7 +33,7 @@ typedef kafka_topic_partition_intern object_intern; -static HashTable *get_debug_info(Z_RDKAFKA_OBJ *object, int *is_temp); +static HashTable *get_debug_info(zend_object *object, int *is_temp); zend_class_entry * ce_kafka_topic_partition; @@ -84,7 +84,7 @@ kafka_topic_partition_intern * get_topic_partition_object(zval *z) /* {{{ */ return get_object(z); } /* }}} */ -static HashTable *get_debug_info(Z_RDKAFKA_OBJ *object, int *is_temp) /* {{{ */ +static HashTable *get_debug_info(zend_object *object, int *is_temp) /* {{{ */ { zval ary; object_intern *intern; @@ -93,7 +93,7 @@ static HashTable *get_debug_info(Z_RDKAFKA_OBJ *object, int *is_temp) /* {{{ */ array_init(&ary); - intern = rdkafka_get_debug_object(object_intern, object); + intern = php_kafka_from_obj(object_intern, object); if (!intern || !intern->topic) { return Z_ARRVAL(ary);