1 /*
2    +----------------------------------------------------------------------+
3    | PHP Version 5                                                        |
4    +----------------------------------------------------------------------+
5    | Copyright (c) 1997-2021 The PHP Group                                |
6    +----------------------------------------------------------------------+
7    | This source file is subject to version 3.01 of the PHP license,      |
8    | that is bundled with this package in the file LICENSE, and is        |
9    | available through the world-wide-web at the following url:           |
10    | http://www.php.net/license/3_01.txt                                  |
11    | If you did not receive a copy of the PHP license and are unable to   |
12    | obtain it through the world-wide-web, please send a note to          |
13    | license@php.net so we can mail you a copy immediately.               |
14    +----------------------------------------------------------------------+
15    | Author: Ruslan Osmanov <osmanov@php.net>                             |
16    +----------------------------------------------------------------------+
17 */
18 #include "watcher.h"
19 
20 /* {{{ php_ev_prepare_object_ctor */
php_ev_prepare_object_ctor(INTERNAL_FUNCTION_PARAMETERS,zval * loop,zend_bool ctor,zend_bool start)21 void php_ev_prepare_object_ctor(INTERNAL_FUNCTION_PARAMETERS, zval *loop, zend_bool ctor, zend_bool start)
22 {
23 	zval                  *self;
24 	php_ev_object         *o_self;
25 	php_ev_object         *o_loop;
26 	ev_prepare            *w;
27 
28 	zval                  *data     = NULL;
29 	zend_fcall_info        fci      = empty_fcall_info;
30 	zend_fcall_info_cache  fcc      = empty_fcall_info_cache;
31 	long                   priority = 0;
32 
33 	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "f|z!l",
34 				&fci, &fcc, &data, &priority) == FAILURE) {
35 		return;
36 	}
37 
38 	if (ctor) {
39 		self = getThis();
40 	} else {
41 		PHP_EV_INIT_CLASS_OBJECT(return_value, ev_io_class_entry_ptr);
42 		self = return_value;
43 	}
44 
45 	if (!loop) {
46 		loop = php_ev_default_loop(TSRMLS_C);
47 	}
48 
49 	o_self = (php_ev_object *) zend_object_store_get_object(self TSRMLS_CC);
50 	o_loop = (php_ev_object *) zend_object_store_get_object(loop TSRMLS_CC);
51 	w      = (ev_prepare *) php_ev_new_watcher(sizeof(ev_prepare), self,
52 			PHP_EV_LOOP_OBJECT_FETCH_FROM_OBJECT(o_loop),
53 			&fci, &fcc, data, priority TSRMLS_CC);
54 
55 	w->type = EV_PREPARE;
56 
57 	o_self->ptr = (void *) w;
58 
59 	if (start) {
60 		PHP_EV_WATCHER_START(ev_prepare, w);
61 	}
62 }
63 /* }}} */
64 
65 
66 /* {{{ proto EvPrepare::__construct(callable callback[, mixed data = NULL[, int priority = 0]]) */
PHP_METHOD(EvPrepare,__construct)67 PHP_METHOD(EvPrepare, __construct)
68 {
69 	PHP_EV_WATCHER_CTOR(prepare, NULL);
70 }
71 /* }}} */
72 
73 /* {{{ proto EvPrepare::createStopped(callable callback[, mixed data = NULL[, int priority = 0]]) */
PHP_METHOD(EvPrepare,createStopped)74 PHP_METHOD(EvPrepare, createStopped)
75 {
76 	PHP_EV_WATCHER_FACTORY_NS(prepare, NULL);
77 }
78 /* }}} */
79 
80 /*
81  * Local variables:
82  * tab-width: 4
83  * c-basic-offset: 4
84  * End:
85  * vim600: noet sw=4 ts=4 sts=4 fdm=marker
86  * vim<600: noet sw=4 ts=4 sts=4
87  */
88