26 #include <ext/spl/spl_exceptions.h>
27 #include <zend_exceptions.h>
41 zend_object_std_init(&
intern->std, class_type TSRMLS_CC);
42 object_properties_init(&
intern->std, class_type);
53 return timeval_object;
66 if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET,
67 ZEND_NUM_ARGS() TSRMLS_CC,
"l",
68 µseconds) == FAILURE) {
69 double microsecondsDouble = 0.0;
71 if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET,
72 ZEND_NUM_ARGS() TSRMLS_CC,
"d",
73 µsecondsDouble) == FAILURE) {
74 zend_throw_exception(spl_ce_InvalidArgumentException,
75 "Timeval expects a long or double", 1 TSRMLS_CC);
78 microseconds = (
int64_t)microsecondsDouble;
94 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
"O", &other_obj,
96 zend_throw_exception(spl_ce_InvalidArgumentException,
97 "add expects a Timeval", 1 TSRMLS_CC);
100 wrapped_grpc_timeval *
self =
102 wrapped_grpc_timeval *other =
120 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
"O", &other_obj,
122 zend_throw_exception(spl_ce_InvalidArgumentException,
123 "subtract expects a Timeval", 1 TSRMLS_CC);
126 wrapped_grpc_timeval *
self =
128 wrapped_grpc_timeval *other =
148 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
"OO", &a_obj,
151 zend_throw_exception(spl_ce_InvalidArgumentException,
152 "compare expects two Timevals", 1 TSRMLS_CC);
155 wrapped_grpc_timeval *
a =
157 wrapped_grpc_timeval *
b =
176 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
"OOO", &a_obj,
179 zend_throw_exception(spl_ce_InvalidArgumentException,
180 "compare expects three Timevals", 1 TSRMLS_CC);
183 wrapped_grpc_timeval *
a =
185 wrapped_grpc_timeval *
b =
187 wrapped_grpc_timeval *thresh =
207 zval *grpc_php_timeval_zero =
217 zval *grpc_php_timeval_inf_future =
227 zval *grpc_php_timeval_inf_past =
237 wrapped_grpc_timeval *
this =
242 ZEND_BEGIN_ARG_INFO_EX(arginfo_construct, 0, 0, 1)
243 ZEND_ARG_INFO(0, microseconds)
246 ZEND_BEGIN_ARG_INFO_EX(arginfo_add, 0, 0, 1)
250 ZEND_BEGIN_ARG_INFO_EX(arginfo_compare, 0, 0, 2)
251 ZEND_ARG_INFO(0, a_timeval)
252 ZEND_ARG_INFO(0, b_timeval)
255 ZEND_BEGIN_ARG_INFO_EX(arginfo_infFuture, 0, 0, 0)
258 ZEND_BEGIN_ARG_INFO_EX(arginfo_infPast, 0, 0, 0)
261 ZEND_BEGIN_ARG_INFO_EX(arginfo_now, 0, 0, 0)
264 ZEND_BEGIN_ARG_INFO_EX(arginfo_similar, 0, 0, 3)
265 ZEND_ARG_INFO(0, a_timeval)
266 ZEND_ARG_INFO(0, b_timeval)
267 ZEND_ARG_INFO(0, threshold_timeval)
270 ZEND_BEGIN_ARG_INFO_EX(arginfo_sleepUntil, 0, 0, 0)
273 ZEND_BEGIN_ARG_INFO_EX(arginfo_subtract, 0, 0, 1)
277 ZEND_BEGIN_ARG_INFO_EX(arginfo_zero, 0, 0, 0)
281 PHP_ME(Timeval, __construct, arginfo_construct,
282 ZEND_ACC_PUBLIC | ZEND_ACC_CTOR)
283 PHP_ME(Timeval,
add, arginfo_add,
285 PHP_ME(Timeval,
compare, arginfo_compare,
286 ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
287 PHP_ME(Timeval, infFuture, arginfo_infFuture,
288 ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
289 PHP_ME(Timeval, infPast, arginfo_infPast,
290 ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
291 PHP_ME(Timeval,
now, arginfo_now,
292 ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
293 PHP_ME(Timeval, similar, arginfo_similar,
294 ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
295 PHP_ME(Timeval, sleepUntil, arginfo_sleepUntil,
297 PHP_ME(Timeval, subtract, arginfo_subtract,
299 PHP_ME(Timeval, zero, arginfo_zero,
300 ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)