diff options
Diffstat (limited to 'src/php/ext/grpc/timeval.c')
-rw-r--r-- | src/php/ext/grpc/timeval.c | 54 |
1 files changed, 25 insertions, 29 deletions
diff --git a/src/php/ext/grpc/timeval.c b/src/php/ext/grpc/timeval.c index 7280dde30b..8f0048def6 100644 --- a/src/php/ext/grpc/timeval.c +++ b/src/php/ext/grpc/timeval.c @@ -18,27 +18,11 @@ #include "timeval.h" -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <php.h> -#include <php_ini.h> -#include <ext/standard/info.h> #include <ext/spl/spl_exceptions.h> -#include "php_grpc.h" - #include <zend_exceptions.h> -#include <stdbool.h> - -#include <grpc/grpc.h> -#include <grpc/support/time.h> - zend_class_entry *grpc_ce_timeval; -#if PHP_MAJOR_VERSION >= 7 -static zend_object_handlers timeval_ce_handlers; -#endif +PHP_GRPC_DECLARE_OBJECT_HANDLER(timeval_ce_handlers) /* Frees and destroys an instance of wrapped_grpc_call */ PHP_GRPC_FREE_WRAPPED_FUNC_START(wrapped_grpc_timeval) @@ -58,7 +42,8 @@ zval *grpc_php_wrap_timeval(gpr_timespec wrapped TSRMLS_DC) { zval *timeval_object; PHP_GRPC_MAKE_STD_ZVAL(timeval_object); object_init_ex(timeval_object, grpc_ce_timeval); - wrapped_grpc_timeval *timeval = Z_WRAPPED_GRPC_TIMEVAL_P(timeval_object); + wrapped_grpc_timeval *timeval = + PHP_GRPC_GET_WRAPPED_OBJECT(wrapped_grpc_timeval, timeval_object); memcpy(&timeval->wrapped, &wrapped, sizeof(gpr_timespec)); return timeval_object; } @@ -68,7 +53,8 @@ zval *grpc_php_wrap_timeval(gpr_timespec wrapped TSRMLS_DC) { * @param long $microseconds The number of microseconds in the interval */ PHP_METHOD(Timeval, __construct) { - wrapped_grpc_timeval *timeval = Z_WRAPPED_GRPC_TIMEVAL_P(getThis()); + wrapped_grpc_timeval *timeval = + PHP_GRPC_GET_WRAPPED_OBJECT(wrapped_grpc_timeval, getThis()); php_grpc_long microseconds; /* "l" == 1 long */ @@ -98,8 +84,10 @@ PHP_METHOD(Timeval, add) { "add expects a Timeval", 1 TSRMLS_CC); return; } - wrapped_grpc_timeval *self = Z_WRAPPED_GRPC_TIMEVAL_P(getThis()); - wrapped_grpc_timeval *other = Z_WRAPPED_GRPC_TIMEVAL_P(other_obj); + wrapped_grpc_timeval *self = + PHP_GRPC_GET_WRAPPED_OBJECT(wrapped_grpc_timeval, getThis()); + wrapped_grpc_timeval *other = + PHP_GRPC_GET_WRAPPED_OBJECT(wrapped_grpc_timeval, other_obj); zval *sum = grpc_php_wrap_timeval(gpr_time_add(self->wrapped, other->wrapped) TSRMLS_CC); @@ -122,8 +110,10 @@ PHP_METHOD(Timeval, subtract) { "subtract expects a Timeval", 1 TSRMLS_CC); return; } - wrapped_grpc_timeval *self = Z_WRAPPED_GRPC_TIMEVAL_P(getThis()); - wrapped_grpc_timeval *other = Z_WRAPPED_GRPC_TIMEVAL_P(other_obj); + wrapped_grpc_timeval *self = + PHP_GRPC_GET_WRAPPED_OBJECT(wrapped_grpc_timeval, getThis()); + wrapped_grpc_timeval *other = + PHP_GRPC_GET_WRAPPED_OBJECT(wrapped_grpc_timeval, other_obj); zval *diff = grpc_php_wrap_timeval(gpr_time_sub(self->wrapped, other->wrapped) TSRMLS_CC); @@ -149,8 +139,10 @@ PHP_METHOD(Timeval, compare) { "compare expects two Timevals", 1 TSRMLS_CC); return; } - wrapped_grpc_timeval *a = Z_WRAPPED_GRPC_TIMEVAL_P(a_obj); - wrapped_grpc_timeval *b = Z_WRAPPED_GRPC_TIMEVAL_P(b_obj); + wrapped_grpc_timeval *a = + PHP_GRPC_GET_WRAPPED_OBJECT(wrapped_grpc_timeval, a_obj); + wrapped_grpc_timeval *b = + PHP_GRPC_GET_WRAPPED_OBJECT(wrapped_grpc_timeval, b_obj); long result = gpr_time_cmp(a->wrapped, b->wrapped); RETURN_LONG(result); } @@ -175,9 +167,12 @@ PHP_METHOD(Timeval, similar) { "compare expects three Timevals", 1 TSRMLS_CC); return; } - wrapped_grpc_timeval *a = Z_WRAPPED_GRPC_TIMEVAL_P(a_obj); - wrapped_grpc_timeval *b = Z_WRAPPED_GRPC_TIMEVAL_P(b_obj); - wrapped_grpc_timeval *thresh = Z_WRAPPED_GRPC_TIMEVAL_P(thresh_obj); + wrapped_grpc_timeval *a = + PHP_GRPC_GET_WRAPPED_OBJECT(wrapped_grpc_timeval, a_obj); + wrapped_grpc_timeval *b = + PHP_GRPC_GET_WRAPPED_OBJECT(wrapped_grpc_timeval, b_obj); + wrapped_grpc_timeval *thresh = + PHP_GRPC_GET_WRAPPED_OBJECT(wrapped_grpc_timeval, thresh_obj); int result = gpr_time_similar(a->wrapped, b->wrapped, thresh->wrapped); RETURN_BOOL(result); } @@ -226,7 +221,8 @@ PHP_METHOD(Timeval, infPast) { * @return void */ PHP_METHOD(Timeval, sleepUntil) { - wrapped_grpc_timeval *this = Z_WRAPPED_GRPC_TIMEVAL_P(getThis()); + wrapped_grpc_timeval *this = + PHP_GRPC_GET_WRAPPED_OBJECT(wrapped_grpc_timeval, getThis()); gpr_sleep_until(this->wrapped); } |