Commits

Ruslan Osmanov committed 25a4961

Add: EvEatcher methods: get_loop, keepalive, set_callback
Add: EvIo::set
Dev: EvIo props
Refact

  • Participants
  • Parent commits a2b1ff0

Comments (0)

Files changed (10)

 
 /* Override `data` member of the watcher structs.
  * See types.h and libev/ev.h */
-#define EV_COMMON                                                         \
+#define EV_COMMON                                                                    \
     zval                        *self;      /* this struct */                        \
     zval                        *data;      /* custom var attached by user */        \
     php_ev_loop                 *loop;                                               \
 ZEND_BEGIN_ARG_INFO_EX(arginfo_ev_watcher_feed, 0, 0, 1)
 	ZEND_ARG_INFO(0, revents)
 ZEND_END_ARG_INFO();
+ZEND_BEGIN_ARG_INFO_EX(arginfo_ev_watcher_keepalive, 0, 0, 0)
+	ZEND_ARG_INFO(0, value)
+ZEND_END_ARG_INFO();
+ZEND_BEGIN_ARG_INFO_EX(arginfo_ev_watcher_set_callback, 0, 0, 1)
+	ZEND_ARG_INFO(0, callback)
+ZEND_END_ARG_INFO();
+
 /* EvWatcher }}} */
 
 /* {{{ EvIo */
 	ZEND_ARG_INFO(0, data)
 	ZEND_ARG_INFO(0, priority)
 ZEND_END_ARG_INFO();
+ZEND_BEGIN_ARG_INFO_EX(arginfo_ev_io_set, 0, 0, 2)
+	ZEND_ARG_INFO(0, fd)
+	ZEND_ARG_INFO(0, events)
+ZEND_END_ARG_INFO();
 /* EvIo }}} */
 /* ARGINFO }}} */
 
 const zend_function_entry ev_watcher_class_entry_functions[] = {
 	PHP_ABSTRACT_ME(EvWatcher, __construct, NULL)
 
-	PHP_ME(EvWatcher, start,   arginfo_ev__watcher_void,  ZEND_ACC_PUBLIC)
-	PHP_ME(EvWatcher, stop,    arginfo_ev__watcher_void,  ZEND_ACC_PUBLIC)
-	PHP_ME(EvWatcher, clear,   arginfo_ev__watcher_void,  ZEND_ACC_PUBLIC)
-	PHP_ME(EvWatcher, invoke,  arginfo_ev_watcher_invoke, ZEND_ACC_PUBLIC)
-	PHP_ME(EvWatcher, feed,    arginfo_ev_watcher_feed,   ZEND_ACC_PUBLIC)
-	PHP_ME(EvWatcher, getLoop, arginfo_ev__watcher_void,  ZEND_ACC_PUBLIC)
+	PHP_ME(EvWatcher, start,        arginfo_ev__watcher_void,        ZEND_ACC_PUBLIC)
+	PHP_ME(EvWatcher, stop,         arginfo_ev__watcher_void,        ZEND_ACC_PUBLIC)
+	PHP_ME(EvWatcher, clear,        arginfo_ev__watcher_void,        ZEND_ACC_PUBLIC)
+	PHP_ME(EvWatcher, invoke,       arginfo_ev_watcher_invoke,       ZEND_ACC_PUBLIC)
+	PHP_ME(EvWatcher, feed,         arginfo_ev_watcher_feed,         ZEND_ACC_PUBLIC)
+	PHP_ME(EvWatcher, get_loop,     arginfo_ev__watcher_void,        ZEND_ACC_PUBLIC)
+	PHP_ME(EvWatcher, keepalive,    arginfo_ev_watcher_keepalive,    ZEND_ACC_PUBLIC)
+	PHP_ME(EvWatcher, set_callback, arginfo_ev_watcher_set_callback, ZEND_ACC_PUBLIC)
 
 	{ NULL, NULL, NULL }
 };
 
 /* {{{ ev_io_class_entry_functions */
 const zend_function_entry ev_io_class_entry_functions[] = {
-	PHP_ME(EvIo, __construct, arginfo_ev_io, ZEND_ACC_PUBLIC | ZEND_ACC_CTOR)
+	PHP_ME(EvIo, __construct, arginfo_ev_io,     ZEND_ACC_PUBLIC  | ZEND_ACC_CTOR)
+	PHP_ME(EvIo, set,         arginfo_ev_io_set, ZEND_ACC_PUBLIC)
 	{ NULL, NULL, NULL }
 };
 /* }}} */
 PHP_METHOD(EvWatcher, clear);
 PHP_METHOD(EvWatcher, invoke);
 PHP_METHOD(EvWatcher, feed);
-PHP_METHOD(EvWatcher, getLoop);
+PHP_METHOD(EvWatcher, get_loop);
+PHP_METHOD(EvWatcher, keepalive);
+PHP_METHOD(EvWatcher, set_callback);
 /* }}} */
 
 /* {{{ EvIo */
 PHP_METHOD(EvIo, __construct);
+PHP_METHOD(EvIo, set);
 /* }}} */
 
 #endif /* PHP_EV_FE_H */
    | Author: Ruslan Osmanov <osmanov@php.net>                             |
    +----------------------------------------------------------------------+
 */
-
+#include "watcher.h"
 
 /* {{{ proto EvIo::__construct(resource fd, int events, EvLoop loop, callback callback[, mixed data = NULL[, int priority = 0]]) */
 PHP_METHOD(EvIo, __construct)
 {
-	zval          *self;
-	zval          *z_stream;
-	php_ev_object *o_self;
-	php_ev_object *o_loop;
-	ev_io         *io_watcher;
+	zval                  *self;
+	zval                  *z_stream;
+	php_ev_object         *o_self;
+	php_ev_object         *o_loop;
+	ev_io                 *io_watcher;
 
 	zval                  *loop;
-	zval                  *data      = NULL;
+	zval                  *data       = NULL;
 	php_stream            *fd_stream;
-	zend_fcall_info        fci       = empty_fcall_info;
-	zend_fcall_info_cache  fcc       = empty_fcall_info_cache;
-	long                   priority  = 0;
+	zend_fcall_info        fci        = empty_fcall_info;
+	zend_fcall_info_cache  fcc        = empty_fcall_info_cache;
+	long                   priority   = 0;
 	long                   events;
 
 	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rlOf|z!l",
 	}
 
 	self    = getThis();
-	o_self  = (php_ev_object *)zend_object_store_get_object(self TSRMLS_CC);
-	o_loop  = (php_ev_object *)zend_object_store_get_object(loop TSRMLS_CC);
-	io_watcher = (ev_io *)php_ev_new_watcher(sizeof(ev_io), self,
+	o_self  = (php_ev_object *) zend_object_store_get_object(self TSRMLS_CC);
+	o_loop  = (php_ev_object *) zend_object_store_get_object(loop TSRMLS_CC);
+	io_watcher = (ev_io *) php_ev_new_watcher(sizeof(ev_io), self,
 			PHP_EV_LOOP_OBJECT_FETCH_FROM_OBJECT(o_loop),
 			&fci, &fcc, data, priority TSRMLS_CC);
 
 }
 /* }}} */
 
+/* {{{ proto void EvIo::set(resource fd, int events) */
+PHP_METHOD(EvIo, set)
+{
+	zval       *z_stream;
+	long        events;
+	php_stream *fd_stream;
+	ev_io      *io_watcher;
+
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl",
+				&z_stream, &events) == FAILURE) {
+		return;
+	}
+
+	if (events & ~(EV_READ | EV_WRITE)) {
+		php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid events mask");
+		return;
+	}
+
+	php_stream_from_zval_no_verify(fd_stream, &z_stream);
+	if (fd_stream == NULL) {
+		php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed obtaining fd");
+		return;
+	}
+
+	io_watcher = (ev_io *) PHP_EV_WATCHER_FETCH_FROM_THIS();
+
+	PHP_EV_WATCHER_RESET(ev_io, io_watcher, (io_watcher, Z_LVAL_P(z_stream), events));
+}
+/* }}} */
+
 /*
  * Local variables:
  * tab-width: 4
     INIT_PZVAL(zconst);                                       \
     ZVAL_LONG(zconst, name);                                  \
     zend_hash_add(&ce->constants_table, #name, sizeof(#name), \
-            (void*)&zconst, sizeof(zval*), NULL);
+            (void*) &zconst, sizeof(zval*), NULL);
 
 #define PHP_EV_REGISTER_CLASS_ENTRY(name, ce, ce_functions) \
 {                                                           \
 #if PHP_VERSION_ID >= 50300
 # define PHP_EV_FCI_ADDREF(pfci)          \
 {                                         \
+	Z_ADDREF_P(pfci->function_name);      \
     if (pfci->object_ptr) {               \
         Z_ADDREF_P(pfci->object_ptr);     \
     }                                     \
 }
 # define PHP_EV_FCI_DELREF(pfci)          \
 {                                         \
+	zval_ptr_dtor(&pfci->function_name);  \
     if (pfci->object_ptr) {               \
         zval_ptr_dtor(&pfci->object_ptr); \
     }                                     \
 }
 #else
-# define PHP_EV_FCI_ADDREF(pfci)
-# define PHP_EV_FCI_DELREF(pfci)
+# define PHP_EV_FCI_ADDREF(pfci) Z_ADDREF_P(pfci_dst->function_name)
+# define PHP_EV_FCI_DELREF(pfci) zval_ptr_dtor(&pfci->function_name)
 #endif
 
-#define PHP_EV_COPY_FCALL_INFO(pfci_dst, pfcc_dst, pfci, pfcc)                                        \
-{                                                                                                     \
-    if (ZEND_FCI_INITIALIZED(*pfci)) {                                                                \
-        pfci_dst = (zend_fcall_info *) safe_emalloc(1, sizeof(zend_fcall_info), 0);                   \
-        pfcc_dst = (zend_fcall_info_cache *) safe_emalloc(1, sizeof(zend_fcall_info_cache), 0);       \
-                                                                                                      \
-        memcpy(pfci_dst, pfci, sizeof(zend_fcall_info));                                              \
-        memcpy(pfcc_dst, pfcc, sizeof(zend_fcall_info_cache));                                        \
-                                                                                                      \
-        /* Prevent auto-destruction of the zvals within */                                            \
-        Z_ADDREF_P(pfci_dst->function_name);                                                          \
-        PHP_EV_FCI_ADDREF(pfci_dst);                                                                  \
-    } else {                                                                                          \
-        pfci_dst = NULL;                                                                              \
-        pfcc_dst = NULL;                                                                              \
-    }                                                                                                 \
+#define PHP_EV_COPY_FCALL_INFO(pfci_dst, pfcc_dst, pfci, pfcc)                                  \
+{                                                                                               \
+    if (ZEND_FCI_INITIALIZED(*pfci)) {                                                          \
+        pfci_dst = (zend_fcall_info *) safe_emalloc(1, sizeof(zend_fcall_info), 0);             \
+        pfcc_dst = (zend_fcall_info_cache *) safe_emalloc(1, sizeof(zend_fcall_info_cache), 0); \
+                                                                                                \
+        memcpy(pfci_dst, pfci, sizeof(zend_fcall_info));                                        \
+        memcpy(pfcc_dst, pfcc, sizeof(zend_fcall_info_cache));                                  \
+                                                                                                \
+        PHP_EV_FCI_ADDREF(pfci_dst);                                                            \
+    } else {                                                                                    \
+        pfci_dst = NULL;                                                                        \
+        pfcc_dst = NULL;                                                                        \
+    }                                                                                           \
 }
 
 #define PHP_EV_FREE_FCALL_INFO(pfci, pfcc)       \
         efree(pfcc);                             \
                                                  \
         if (ZEND_FCI_INITIALIZED(*pfci)) {       \
-            zval_ptr_dtor(&pfci->function_name); \
             PHP_EV_FCI_DELREF(pfci);             \
         }                                        \
         efree(pfci);                             \
 
 #define PHP_EV_LOOP_OBJECT_FETCH_FROM_OBJECT(obj) (obj ? (php_ev_loop *) obj->ptr : NULL)
 #define PHP_EV_WATCHER_FETCH_FROM_OBJECT(o)       ((ev_watcher *) o->ptr)
+#define PHP_EV_WATCHER_FETCH_FROM_THIS()          \
+	(PHP_EV_WATCHER_FETCH_FROM_OBJECT(((php_ev_object *) zend_object_store_get_object(getThis() TSRMLS_CC))))
 
 #define PHP_EV_LOOP_FETCH_FROM_OBJECT(obj) (obj ? PHP_EV_LOOP_OBJECT_FETCH_FROM_OBJECT(obj)->loop : NULL)
 #define PHP_EV_LOOP_FETCH_FROM_THIS                                                             \
 #include "priv.h"
 #include "watcher.h"
 
-
 /* {{{ EvLoop property handlers */
 
 /* {{{ ev_loop_prop_data_read  */
 
 /* }}} */
 
+/* {{{ EvIo property handlers */
+
+/* {{{ ev_io_prop_fd_read  */
+static int ev_io_prop_fd_read(php_ev_object *obj, zval **retval TSRMLS_DC)
+{
+	ev_io *io_watcher = (ev_io *) PHP_EV_WATCHER_FETCH_FROM_OBJECT(obj);
+	php_stream *stream = php_stream_fopen_from_fd(io_watcher->fd, "r", NULL);
+
+	if (stream) {
+		MAKE_STD_ZVAL(*retval);
+		php_stream_to_zval(stream, *retval);
+	} else {
+		ALLOC_INIT_ZVAL(*retval); // NULL
+	}
+
+	return SUCCESS;
+}
+/* }}} */
+
+/* {{{ ev_io_prop_events_read */
+static int ev_io_prop_events_read(php_ev_object *obj, zval **retval TSRMLS_DC)
+{
+	ev_io *io_watcher = (ev_io *) PHP_EV_WATCHER_FETCH_FROM_OBJECT(obj);
+
+	MAKE_STD_ZVAL(*retval);
+	ZVAL_LONG(*retval, io_watcher->events);
+
+	return SUCCESS;
+}
+/* }}} */
+
+/* }}} */
+
 
 /* {{{ ev_loop_property_entries[] */
 const php_ev_property_entry ev_loop_property_entries[] = {
 	{ZEND_ACC_PUBLIC, "data",       sizeof("data")       - 1, -1, 0, NULL, 0, NULL},
 	{ZEND_ACC_PUBLIC, "is_pending", sizeof("is_pending") - 1, -1, 0, NULL, 0, NULL},
 	{ZEND_ACC_PUBLIC, "priority",   sizeof("priority")   - 1, -1, 0, NULL, 0, NULL},
-	{ZEND_ACC_PUBLIC, "loop",       sizeof("loop")       - 1, -1, 0, NULL, 0, NULL},
 	{0, NULL, 0, -1, 0, NULL, 0, NULL}
 };
 /* }}} */
 
 /* {{{ ev_io_property_entries[] */
 const php_ev_property_entry ev_io_property_entries[] = {
+	{"fd",     sizeof("fd")     - 1, ev_io_prop_fd_read,     NULL},
+	{"events", sizeof("events") - 1, ev_io_prop_events_read, NULL},
     {NULL, 0, NULL, NULL}
 };
 /* }}} */
 
 /* {{{ ev_io_property_entry_info[] */
 const zend_property_info ev_io_property_entry_info[] = {
+	{ZEND_ACC_PUBLIC, "fd",     sizeof("fd")     - 1, -1, 0, NULL, 0, NULL},
+	{ZEND_ACC_PUBLIC, "events", sizeof("events") - 1, -1, 0, NULL, 0, NULL},
 	{0, NULL, 0, -1, 0, NULL, 0, NULL},
 };
 /* }}} */

File tests/002.phpt

---TEST--
-Check for EvIo class
---FILE--
-<?php 
-function cb($watcher, $revents) {
-	echo __FUNCTION__, "() called", PHP_EOL;
-	$watcher->stop();
-	return FALSE;
-}
-$loop       = EvLoop::default_loop();
-$io_watcher = new EvIo(STDIN, EV_READ, $loop, "cb");
-$io_watcher->start();
-$loop->run();
-?>
---EXPECT--
 
 struct ev_watcher;
 
-/* Represents Ev* class object. Extends zend_object */
+/* php_ev_object represents Ev* class object. Extends zend_object */
+
 typedef struct php_ev_object {
 	zend_object  zo;
 	HashTable   *prop_handler;
 	void        *ptr; /* Pointer to ev_watcher or php_ev_loop */
 } php_ev_object;
 
+/* php_ev_loop pointer is stored in php_ev_object.ptr struct member */
+
 typedef struct php_ev_loop {
 	struct ev_loop        *loop;
 	zval                  *data;                       /* User custom data attached to event loop                  */
 } php_ev_loop;
 
 /* Property handlers */
+
 typedef int (*php_ev_read_t)(php_ev_object  *obj, zval **retval TSRMLS_DC);
 typedef int (*php_ev_write_t)(php_ev_object *obj, zval *newval  TSRMLS_DC);
 
 /* Property of an Ev* class */
-typedef struct {
+
+typedef struct php_ev_property_entry {
 	const char     *name;
 	size_t          name_length;
 	php_ev_read_t   read_func;
 /* Defined in ev.c */
 extern zend_class_entry *ev_loop_class_entry_ptr;
 
-#if 0
-inline php_ev_object *php_ev_watcher_loop_obj(const ev_watcher *w TSRMLS_DC)
-{
-	if (w->loop) {
-		/* ????????? */
-		return (php_ev_object *) zend_object_store_get_object(w->loop TSRMLS_CC);
-	}
-
-	return NULL;
-}
-
-inline struct ev_loop *php_ev_watcher_loop_ptr(const ev_watcher *w TSRMLS_DC)
-{
-	php_ev_object *o_loop = php_ev_watcher_loop_obj(w TSRMLS_CC);
-
-	return PHP_EV_LOOP_FETCH_FROM_OBJECT(o_loop);
-}
-#endif
-
 /* {{{ php_ev_set_watcher_priority() */
 inline void php_ev_set_watcher_priority(ev_watcher *watcher, long priority TSRMLS_DC)
 {
 		Z_ADDREF_P(data);
 	}
 
-	php_ev_watcher_self(w) = self;
-	php_ev_watcher_data(w) = data;
-	php_ev_watcher_loop(w) = loop;
+	php_ev_watcher_self(w)  = self;
+	php_ev_watcher_data(w)  = data;
+	php_ev_watcher_loop(w)  = loop;
+	php_ev_watcher_flags(w) = PHP_EV_WATCHER_FLAG_KEEP_ALIVE;
 
 	PHP_EV_COPY_FCALL_INFO(php_ev_watcher_fci(w), php_ev_watcher_fcc(w), pfci, pfcc);
 
 }
 /* }}} */
 
-/* {{{ proto EvLoop EvWatcher::getLoop(void) */
-PHP_METHOD(EvWatcher, getLoop)
+/* {{{ proto EvLoop EvWatcher::get_loop(void) */
+PHP_METHOD(EvWatcher, get_loop)
 {
 	/*
 	 * RETURNING REFERENCES - 
 	 * Sara Goleman, ... p.71
 	 */
 
-	php_ev_object *o_self, *o_loop;
+	php_ev_object *o_self;
 	php_ev_loop *loop;
 	ev_watcher *w;
 
 	RETVAL_ZVAL(zloop, 1, 0);
 
 #if 0
+	php_ev_object *o_loop;
 	Z_TYPE_P(return_value) = IS_OBJECT;
 	object_init_ex(return_value, ev_loop_class_entry_ptr);
 	Z_SET_REFCOUNT_P(return_value, 1);
 
 	if (loop->fci) {
 		if (ZEND_FCI_INITIALIZED(*loop->fci)) {
-			Z_ADDREF_P(loop->fci);
 			PHP_EV_FCI_ADDREF(loop->fci);
 		}
 	}
 }
 /* }}} */
 
+/* {{{ proto int EvWatcher::keepalive(int value = 1) */
+PHP_METHOD(EvWatcher, keepalive)
+{
+	ev_watcher    *w;
+	long           n_value = 1;
+
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l",
+				&n_value) == FAILURE) {
+		return;
+	}
+
+	w = PHP_EV_WATCHER_FETCH_FROM_THIS();
+
+	/* Returning previous state */
+	RETVAL_LONG((w->e_flags & PHP_EV_WATCHER_FLAG_KEEP_ALIVE));
+	n_value = n_value ? PHP_EV_WATCHER_FLAG_KEEP_ALIVE : 0;
+
+	/* Update watcher flags, if keepalive flag changed */
+	if ((n_value ^ w->e_flags) & PHP_EV_WATCHER_FLAG_KEEP_ALIVE) {
+		w->e_flags = (w->e_flags & ~PHP_EV_WATCHER_FLAG_KEEP_ALIVE) | n_value;
+		PHP_EV_WATCHER_REF(w);
+		PHP_EV_WATCHER_UNREF(w);
+	}
+}
+/* }}} */
+
+/* {{{ proto void EvWatcher::set_callback(callable callback) */
+PHP_METHOD(EvWatcher, set_callback)
+{
+	ev_watcher            *w;
+	zend_fcall_info        fci;
+	zend_fcall_info_cache  fcc;
+
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "f",
+				&fci, &fcc) == FAILURE) {
+		return;
+	}
+
+	w = PHP_EV_WATCHER_FETCH_FROM_THIS();
+
+	PHP_EV_FREE_FCALL_INFO(w->fci, w->fcc);
+	PHP_EV_COPY_FCALL_INFO(w->fci, w->fcc, &fci, &fcc);
+}
+/* }}} */
+
 /* Methods }}} */
 
 
         php_ev_watcher_flags(w) |= PHP_EV_WATCHER_FLAG_UNREFED;                 \
     }
 
-#define PHP_EV_WATCHER_REF(w)                                    \
-    if (php_ev_watcher_flags(w) & PHP_EV_WATCHER_FLAG_UNREFED) { \
-        php_ev_watcher_flags(w) &= ~PHP_EV_WATCHER_FLAG_UNREFED; \
-        ev_ref(php_ev_watcher_loop(w)->loop);                    \
+#define PHP_EV_WATCHER_REF(w)                                                   \
+    if (php_ev_watcher_flags(w) & PHP_EV_WATCHER_FLAG_UNREFED) {                \
+        php_ev_watcher_flags(w) &= ~PHP_EV_WATCHER_FLAG_UNREFED;                \
+        ev_ref(php_ev_watcher_loop(w)->loop);                                   \
     }
 
-#define PHP_EV_WATCHER_STOP(t, w)                                  \
-    do {                                                           \
-        PHP_EV_WATCHER_REF(w);                                     \
-        t ## _stop(php_ev_watcher_loop_ptr(w), (t *) w); \
+#define PHP_EV_WATCHER_STOP(t, w)                         \
+    do {                                                  \
+        PHP_EV_WATCHER_REF(w);                            \
+        t ## _stop(php_ev_watcher_loop_ptr(w), (t *) w);  \
     } while(0)
 
-#define PHP_EV_WATCHER_START(t, w)                                  \
-    do {                                                            \
+#define PHP_EV_WATCHER_START(t, w)                        \
+    do {                                                  \
         t ## _start(php_ev_watcher_loop_ptr(w), (t *) w); \
-        PHP_EV_WATCHER_UNREF(w);                                    \
+        PHP_EV_WATCHER_UNREF(w);                          \
     } while(0)
 
+/* Stop, ev_*_set() and start a watcher. Call it when need
+ * to modify probably active watcher.
+ * args - list of args for ev_*_set() with brackets */
+#define PHP_EV_WATCHER_RESET(t, w, args)                  \
+    do {                                                  \
+        int is_active = ev_is_active(w);                  \
+                                                          \
+        if (is_active) {                                  \
+            PHP_EV_WATCHER_STOP(t, w);                    \
+        }                                                 \
+                                                          \
+        t ## _set args;                                   \
+                                                          \
+        if (is_active) {                                  \
+            PHP_EV_WATCHER_START(t, w);                   \
+        }                                                 \
+    } while(0)
 
-#if 0
-inline php_ev_object *php_ev_watcher_loop_obj(const ev_watcher *w TSRMLS_DC);
-inline struct ev_loop *php_ev_watcher_loop_ptr(const ev_watcher *w TSRMLS_DC);
-inline void php_ev_set_watcher_priority(ev_watcher *watcher, long priority TSRMLS_DC);
-#endif
 void php_ev_watcher_callback(EV_P_ ev_watcher *watcher, int revents);
 void *php_ev_new_watcher(size_t size, zval *self, php_ev_loop *loop,
 		const zend_fcall_info *pfci, const zend_fcall_info_cache *pfcc, zval *data, int priority TSRMLS_DC);