Commits

Ruslan Osmanov  committed 8ec8d6c

Fix: exported functions' names

  • Participants
  • Parent commits 4e9addb

Comments (0)

Files changed (9)

 
 	PHP_EVENT_FETCH_BASE(b, zbase);
 
-	RETVAL_STRING(event_base_get_method(b->base), 1);
+	RETURN_STRING((char *)event_base_get_method(b->base), 1);
 }
 /* }}} */
 
 
 /* {{{ proto bool EventBase::stop(void);
  * Tells event_base to stop. */
-PHP_METHOD(EventBase, event_base_loopbreak)
+PHP_METHOD(EventBase, stop)
 {
 	zval             *zbase = getThis();
 	php_event_base_t *b;
 /* {{{ proto long EventBuffer::getLength(void);
  * XXX Create property?
  * Returns the total number of bytes stored in the event buffer. */
-PHP_METHOD(EventBuffer, get_length)
+PHP_METHOD(EventBuffer, getLength)
 {
 	zval               *zbuf = getThis();
 	php_event_buffer_t *b;
  * Move all data from one evbuffer into another evbuffer.
  * This is a destructive add. The data from one buffer moves into the other buffer. However, no unnecessary memory copies occur.
  */
-PHP_METHOD(EventBuffer, add_buffer)
+PHP_METHOD(EventBuffer, addBuffer)
 {
 	php_event_buffer_t *b_out     , *b_in;
 	zval               *zbuf_out  , *zbuf_in;

File buffer_event.c

 
 /* {{{ proto int EventBufferEvent::getEnabled(void);
  * Returns bitmask of events currently enabled on the buffer event. */
-PHP_METHOD(EventBufferEvent,get_enabled)
+PHP_METHOD(EventBufferEvent, getEnabled)
 {
 	zval               *zbevent = getThis();
 	php_event_bevent_t *bev;
 
 /* {{{ proto void EventBufferEvent::setWatermark(int events, int lowmark, int highmark);
  * Adjusts the read watermarks, the write watermarks, or both, of a single bufferevent. */
-PHP_METHOD(EventBufferEvent,setwatermark)
+PHP_METHOD(EventBufferEvent, setWatermark)
 {
 	zval               *zbevent = getThis();
 	php_event_bevent_t *bev;
 
 /* {{{ proto bool EventBufferEvent::writeBuffer(EventBuffer buf);
  * Adds contents of the entire buffer to a buffer event's output buffer. */
-PHP_METHOD(EventBufferEvent,write_buffer)
+PHP_METHOD(EventBufferEvent, writeBuffer)
 {
 	zval               *zbevent = getThis();
 	php_event_bevent_t *bev;
 
 /* {{{ proto bool EventBufferEvent::setTimeouts(double timeout_read, double timeout_write);
  * Set the read and write timeout for a bufferevent. */
-PHP_METHOD(EventBufferEvent,set_timeouts)
+PHP_METHOD(EventBufferEvent, setTimeouts)
 {
 	zval               *zbevent       = getThis();
 	php_event_bevent_t *bev;
 
 /* {{{ proto void EventDnsBase::setSearchNdots(int ndots);
  */
-PHP_METHOD(EventDnsBase, base_search_ndots_set)
+PHP_METHOD(EventDnsBase, setSearchNdots)
 {
 	php_event_dns_base_t *dnsb;
 	zval                 *zdns_base = getThis();
 
 /* {{{ proto int EventDnsBase::countNameservers(void);
  */
-PHP_METHOD(EventDnsBase, base_count_nameservers)
+PHP_METHOD(EventDnsBase, countNameservers)
 {
 	php_event_dns_base_t *dnsb;
 	zval                 *zdns_base = getThis();

File examples/misc.php

 <?php
 /* {{{ Config & supported stuff */
 echo "Supported methods:\n";
-foreach (event_get_supported_methods() as $m) {
+foreach (Event::getSupportedMethods() as $m) {
 	echo $m, PHP_EOL;
 }
 
 // Avoiding "select" method
-$cfg = event_config_new();
-if (event_config_avoid_method($cfg, "select")) {
+$cfg = new EventConfig();
+if ($cfg->avoidMethod("select")) {
 	echo "`select' method avoided\n";
 }
 
 // Create event_base associated with the config
-$base = event_base_new_with_config($cfg);
-echo "Event method used: ", event_base_get_method($base), PHP_EOL;
+$base = new EventBase($cfg);
+echo "Event method used: ", $base->getMethod(), PHP_EOL;
 
 echo "Features:\n";
-$features = event_base_get_features($base);
+$features = $base->getFeatures();
 ($features & EVENT_FEATURE_ET) and print("ET - edge-triggered IO\n");
 ($features & EVENT_FEATURE_O1) and print("O1 - O(1) operation for adding/deletting events\n");
 ($features & EVENT_FEATURE_FDS) and print("FDS - arbitrary file descriptor types, and not just sockets\n");
 
 // Require FDS feature
-if (event_config_require_features($cfg, EVENT_FEATURE_FDS)) {
+if ($cfg->requireFeatures(EVENT_FEATURE_FDS)) {
 	echo "FDS feature is now requried\n";
 
-	$base = event_base_new_with_config($cfg);
-	(event_base_get_features($base) & EVENT_FEATURE_FDS)
+	$base = new EventBase($cfg);
+	($base->getFeatures() & EVENT_FEATURE_FDS)
 		and print("FDS - arbitrary file descriptor types, and not just sockets\n");
 }
 /* }}} */
 
 /* {{{ Base */
-$base = event_base_new();
-$event = event_new($base, STDIN, EVENT_READ | EVENT_PERSIST, function ($fd, $events, $arg) {
+$base = new EventBase();
+$event = new Event($base, STDIN, EVENT_READ | EVENT_PERSIST, function ($fd, $events, $arg) {
 	static $max_iterations = 0;
 
     if (++$max_iterations >= 5) {
 		/* exit after 5 iterations with timeout of 2.33 seconds */
 		echo "Stopping...\n";
-        event_base_loopexit($arg[0], 2.33);
+        $arg[0]->exit(2.33);
     }
 
     echo fgets($fd);
 }, array (&$base));
 
-event_add($event);
-event_base_loop($base);
+$event->add();
+$base->loop();
 /* Base }}} */
 ?>
 
 /* }}} */
 
 const zend_function_entry php_event_util_ce_functions[] = {/* {{{ */
-	PHP_ME(EventUtil, getLastSocketErrno, arginfo_event_socket_1, ZEND_ACC_PUBLIC)
-	PHP_ME(EventUtil, getLastSocketError, arginfo_event_socket_1, ZEND_ACC_PUBLIC)
+	PHP_ABSTRACT_ME(EventUtil, __construct, NULL)
+
+	PHP_ME(EventUtil, getLastSocketErrno, arginfo_event_socket_1, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
+	PHP_ME(EventUtil, getLastSocketError, arginfo_event_socket_1, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
 
 	PHP_FE_END
 };

File http_connection.c

 
 /* {{{ proto EventHttpConnection EventHttpConnection::__construct(EventBase base, EventDnsBase dns_base, string address, int port);
  * */
-PHP_METHOD(EventHttpConnection, connection_base_new)
+PHP_METHOD(EventHttpConnection, __construct)
 {
 	zval                     *zbase;
 	php_event_base_t         *b;
 
 /* {{{ proto void EventHttpConnection::setMaxHeadersSize(int max_size);
  */
-PHP_METHOD(EventHttpConnection, connection_set_max_headers_size)
+PHP_METHOD(EventHttpConnection, setMaxHeadersSize)
 {
 	zval                  *zevcon = getThis();
 	php_event_http_conn_t *evcon;
 
 /* {{{ proto void EventHttpConnection::setRetries(int retries);
  */
-PHP_METHOD(EventHttpConnection, connection_set_retries)
+PHP_METHOD(EventHttpConnection, setRetries)
 {
 	zval                  *zevcon = getThis();
 	php_event_http_conn_t *evcon;
 /* {{{ proto void EventListener::setErrorCallback(callable cb);
  * Set event listener's error callback
  */
-PHP_METHOD(EventListener, set_error_cb)
+PHP_METHOD(EventListener, setErrorCallback)
 {
 	zval                  *zlistener = getThis();
 	php_event_listener_t  *l;
 /* }}} */
 
 
-
 /* {{{ register_object */
 static zend_always_inline zend_object_value register_object(zend_class_entry *ce, void *obj, zend_objects_free_object_storage_t func_free_storage TSRMLS_DC)
 {
 /* {{{ object_new
  * Allocates new object with it's properties.
  * size is a size of struct implementing php_event_abstract_object_t */
-static php_event_abstract_object_t *object_new(zend_class_entry *ce, size_t size TSRMLS_DC)
+static void *object_new(zend_class_entry *ce, size_t size TSRMLS_DC)
 {
+	void *ptr;
 	php_event_abstract_object_t *obj;
 	zend_class_entry *ce_parent = ce;
 
-	obj = ecalloc(1, sizeof(size));
+	ptr = ecalloc(1, sizeof(size));
+	obj = (php_event_abstract_object_t *) ptr;
 
 	while (ce_parent->type != ZEND_INTERNAL_CLASS && ce_parent->parent != NULL) {
 		ce_parent = ce_parent->parent;
 	zend_object_std_init(&obj->zo, ce TSRMLS_CC);
 	object_properties_init(&obj->zo, ce);
 
-	return obj;
+	return ptr;
 }
 /* }}} */
 
  * Event object ctor */
 static zend_object_value event_object_create(zend_class_entry *ce TSRMLS_DC)
 {
-	php_event_abstract_object_t *obj = object_new(ce, sizeof(php_event_t) TSRMLS_CC);
+	php_event_abstract_object_t *obj = (php_event_abstract_object_t *) object_new(ce, sizeof(php_event_t) TSRMLS_CC);
 
 	return register_object(ce, (void *) obj, event_object_free_storage TSRMLS_CC);
 }
  * EventBase object ctor */
 static zend_object_value event_base_object_create(zend_class_entry *ce TSRMLS_DC)
 {
-	php_event_abstract_object_t *obj = object_new(ce, sizeof(php_event_base_t) TSRMLS_CC);
+	php_event_abstract_object_t *obj = (php_event_abstract_object_t *) object_new(ce, sizeof(php_event_base_t) TSRMLS_CC);
 
 	return register_object(ce, (void *) obj, event_base_object_free_storage TSRMLS_CC);
 }
  * EventConfig object ctor */
 static zend_object_value event_config_object_create(zend_class_entry *ce TSRMLS_DC)
 {
-	php_event_abstract_object_t *obj = object_new(ce, sizeof(php_event_config_t) TSRMLS_CC);
+	php_event_abstract_object_t *obj = (php_event_abstract_object_t *) object_new(ce, sizeof(php_event_config_t) TSRMLS_CC);
 
 	return register_object(ce, (void *) obj, event_config_object_free_storage TSRMLS_CC);
 }
  * EventBufferEvent object ctor */
 static zend_object_value event_bevent_object_create(zend_class_entry *ce TSRMLS_DC)
 {
-	php_event_abstract_object_t *obj = object_new(ce, sizeof(php_event_bevent_t) TSRMLS_CC);
+	php_event_abstract_object_t *obj = (php_event_abstract_object_t *) object_new(ce, sizeof(php_event_bevent_t) TSRMLS_CC);
 
 	return register_object(ce, (void *) obj, event_bevent_object_free_storage TSRMLS_CC);
 }
  * EventBuffer object ctor */
 static zend_object_value event_buffer_object_create(zend_class_entry *ce TSRMLS_DC)
 {
-	php_event_abstract_object_t *obj = object_new(ce, sizeof(php_event_buffer_t) TSRMLS_CC);
+	php_event_abstract_object_t *obj = (php_event_abstract_object_t *) object_new(ce, sizeof(php_event_buffer_t) TSRMLS_CC);
 
 	return register_object(ce, (void *) obj, event_buffer_object_free_storage TSRMLS_CC);
 }
  * EventDnsBase object ctor */
 static zend_object_value event_dns_base_object_create(zend_class_entry *ce TSRMLS_DC)
 {
-	php_event_abstract_object_t *obj = object_new(ce, sizeof(php_event_dns_base_t) TSRMLS_CC);
+	php_event_abstract_object_t *obj = (php_event_abstract_object_t *) object_new(ce, sizeof(php_event_dns_base_t) TSRMLS_CC);
 
 	return register_object(ce, (void *) obj, event_dns_base_object_free_storage TSRMLS_CC);
 }
  * EventListener object ctor */
 static zend_object_value event_listener_object_create(zend_class_entry *ce TSRMLS_DC)
 {
-	php_event_abstract_object_t *obj = object_new(ce, sizeof(php_event_listener_t) TSRMLS_CC);
+	php_event_abstract_object_t *obj = (php_event_abstract_object_t *) object_new(ce, sizeof(php_event_listener_t) TSRMLS_CC);
 
 	return register_object(ce, (void *) obj, event_listener_object_free_storage TSRMLS_CC);
 }
  * EventHttpConnection object ctor */
 static zend_object_value event_http_conn_object_create(zend_class_entry *ce TSRMLS_DC)
 {
-	php_event_abstract_object_t *obj = object_new(ce, sizeof(php_event_http_conn_t) TSRMLS_CC);
+	php_event_abstract_object_t *obj = (php_event_abstract_object_t *) object_new(ce, sizeof(php_event_http_conn_t) TSRMLS_CC);
 
 	return register_object(ce, (void *) obj, event_http_conn_object_free_storage TSRMLS_CC);
 }
  * EventHttp object ctor */
 static zend_object_value event_http_object_create(zend_class_entry *ce TSRMLS_DC)
 {
-	php_event_abstract_object_t *obj = object_new(ce, sizeof(php_event_http_t) TSRMLS_CC);
+	php_event_abstract_object_t *obj = (php_event_abstract_object_t *) object_new(ce, sizeof(php_event_http_t) TSRMLS_CC);
 
 	return register_object(ce, (void *) obj, event_http_object_free_storage TSRMLS_CC);
 }
 	/* EventUtil is a singleton. This function must never be called */
 	PHP_EVENT_ASSERT(0);
 
-	php_event_abstract_object_t *obj = object_new(ce, sizeof(php_event_abstract_object_t) TSRMLS_CC);
+	php_event_abstract_object_t *obj = (php_event_abstract_object_t *) object_new(ce, sizeof(php_event_abstract_object_t) TSRMLS_CC);
 
 	return register_object(ce, (void *) obj, event_generic_object_free_storage TSRMLS_CC);
 }
 			php_event_util_ce_functions);
 	ce = php_event_util_ce;
 	ce->ce_flags |= ZEND_ACC_FINAL_CLASS;
+
 }
 /* }}} */
 
 	zend_hash_init(&classes, 0, NULL, NULL, 1);
 	register_classes(TSRMLS_C);
 
+	/* XXX Move constants to corresponding classes */
+
 	/* Loop flags */
 	PHP_EVENT_REG_CONST_LONG(EVENT_LOOP_ONCE,     EVLOOP_ONCE);
 	PHP_EVENT_REG_CONST_LONG(EVENT_LOOP_NONBLOCK, EVLOOP_NONBLOCK);