update for libuv 1.0.0rc2, updated tests for api changes

This commit is contained in:
Steve Rhoades 2014-11-07 21:42:17 +00:00
parent 84d7e09ce6
commit 1ea6c5aca4
11 changed files with 68 additions and 23 deletions

View File

@ -875,14 +875,14 @@ static void php_uv_fs_common(uv_fs_type fs_type, INTERNAL_FUNCTION_PARAMETERS)
PHP_UV_FS_SETUP_AND_EXECUTE(open, path, flag, mode);
break;
}
case UV_FS_READDIR:
case UV_FS_SCANDIR:
{
char *path;
int path_len = 0;
long flags;
PHP_UV_FS_PARSE_PARAMETERS("zslf!", &zloop, &path, &path_len, &flags, &fci, &fcc);
PHP_UV_FS_SETUP_AND_EXECUTE(readdir, path, flags);
PHP_UV_FS_SETUP_AND_EXECUTE(scandir, path, flags);
break;
}
case UV_FS_LSTAT:
@ -1798,7 +1798,7 @@ static void php_uv_fs_cb(uv_fs_t* req)
argc = 1;
break;
}
case UV_FS_READDIR:
case UV_FS_SCANDIR:
{
zval *dirent;
int nnames, i = 0;
@ -2133,7 +2133,7 @@ static void php_uv_idle_cb(uv_timer_t *handle)
params[0] = &idle;
php_uv_do_callback2(&retval_ptr, uv, params, 2, PHP_UV_IDLE_CB TSRMLS_CC);
php_uv_do_callback2(&retval_ptr, uv, params, 1, PHP_UV_IDLE_CB TSRMLS_CC);
if (retval_ptr != NULL) {
@ -4839,6 +4839,7 @@ PHP_FUNCTION(uv_pipe_pending_count)
{
php_uv_t *uv;
zval *handle;
int count;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
"z",&handle) == FAILURE) {
@ -4848,7 +4849,8 @@ PHP_FUNCTION(uv_pipe_pending_count)
PHP_UV_TYPE_CHECK(uv, IS_UV_PIPE);
uv_pipe_pending_count(&uv->uv.pipe);
count = uv_pipe_pending_count(&uv->uv.pipe);
RETURN_LONG(count);
}
/* }}} */
@ -4858,6 +4860,7 @@ PHP_FUNCTION(uv_pipe_pending_type)
{
php_uv_t *uv;
zval *handle;
uv_handle_type ret;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
"z",&handle) == FAILURE) {
@ -4867,7 +4870,8 @@ PHP_FUNCTION(uv_pipe_pending_type)
PHP_UV_TYPE_CHECK(uv, IS_UV_PIPE);
uv_pipe_pending_type(&uv->uv.pipe);
ret = uv_pipe_pending_type(&uv->uv.pipe);
RETURN_LONG(ret);
}
/* }}} */
@ -5934,7 +5938,15 @@ PHP_FUNCTION(uv_fs_fstat)
*/
PHP_FUNCTION(uv_fs_readdir)
{
php_uv_fs_common(UV_FS_READDIR, INTERNAL_FUNCTION_PARAM_PASSTHRU);
php_uv_fs_common(UV_FS_SCANDIR, INTERNAL_FUNCTION_PARAM_PASSTHRU);
}
/* }}} */
/* {{{ proto uv_fs_scandir(resource $loop, string $path, long $flags, callable $callback)
* */
PHP_FUNCTION(uv_fs_scandir)
{
php_uv_fs_common(UV_FS_SCANDIR, INTERNAL_FUNCTION_PARAM_PASSTHRU);
}
/* }}} */

View File

@ -3,7 +3,7 @@ Check for uv_async
--FILE--
<?php
$loop = uv_default_loop();
$async = uv_async_init($loop, function($async, $status){
$async = uv_async_init($loop, function($async){
echo "Hello";
uv_close($async);
});
@ -12,4 +12,4 @@ uv_async_send($async);
uv_run();
--EXPECT--
Hello
Hello

View File

@ -16,11 +16,11 @@ uv_idle_start($idle, function($stat) use (&$i, $idle, $loop){
}
});
uv_check_start($check, function($check, $status){
uv_check_start($check, function($check){
echo "Hello";
uv_check_stop($check);
});
uv_run();
--EXPECT--
Hello
Hello

View File

@ -5,11 +5,11 @@ Check for uv_prepare
$loop = uv_default_loop();
$prepare = uv_prepare_init($loop);
uv_prepare_start($prepare, function($rsc, $status){
uv_prepare_start($prepare, function($rsc){
echo "Hello";
uv_unref($rsc);
});
uv_run();
--EXPECT--
Hello
Hello

View File

@ -6,7 +6,7 @@ $loop = uv_default_loop();
$timer = uv_timer_init();
$i = 0;
uv_timer_start($timer, 10, 10, function($timer, $stat)
uv_timer_start($timer, 10, 10, function($timer)
use (&$i) {
echo "count: {$i}" . PHP_EOL;
@ -26,4 +26,4 @@ count: 0
count: 1
count: 2
count: 3
finished
finished

View File

@ -5,13 +5,39 @@ Check for #14
$loop = uv_default_loop();
$filename ="does_not_exist.txt";
uv_fs_stat($loop, $filename, function ($result, $stat) {
echo $result . PHP_EOL;
if($result < 0) {
echo 'OK' . PHP_EOL;
} else {
echo 'FAILED: uv_fs_stat should have returned a value less than 0' . PHP_EOL;
}
if (is_null($stat)) {
echo "NULL" . PHP_EOL;
} else {
echo "FAILED: uv_fs_stat \$stat return value should be NULL" . PHP_EOL;
}
});
$filename = tempnam(sys_get_temp_dir(), 'test-no14');
uv_fs_stat($loop, $filename, function ($result, $stat) {
if($result === 0) {
echo 'OK' . PHP_EOL;
} else {
echo "FAILED: uv_fs_stat should have returned a result of 0" . PHP_EOL;
}
if(!empty($stat)) {
echo 'OK' . PHP_EOL;
} else {
echo 'FAILED: $stat should be an array with values' . PHP_EOL;
}
});
uv_run();
--EXPECT--
-1
NULL
OK
NULL
OK
OK

View File

@ -29,4 +29,4 @@ uv_tcp_connect($c, uv_ip4_addr($addrinfo['address'],$addrinfo['port']), function
uv_run();
--EXPECT--
Hello
Hello

View File

@ -19,7 +19,7 @@ uv_spawn(uv_default_loop(), "php", array('-r','echo "WORLD";'), $stdio, dirname(
}, $flags);
uv_read2_start($out, function($out, $nread, $buffer, $stat){
uv_read_start($out, function($out, $nread, $buffer) {
echo $buffer;
uv_close($out,function(){});
@ -28,4 +28,4 @@ uv_read2_start($out, function($out, $nread, $buffer, $stat){
uv_run();
--EXPECT--
HELLO WORLD
HELLO WORLD

View File

@ -4,7 +4,12 @@ Check for uv_chdir
<?php
uv_chdir(); // don't SEGV
uv_chdir(dirname(__FILE__));
if(uv_chdir(dirname(__FILE__))) {
echo "OK\n";
} else {
echo "FAILED: expected uv_chdir to return true";
}
if (uv_cwd() == dirname(__FILE__)) {
echo "OK";
} else {
@ -15,3 +20,4 @@ if (uv_cwd() == dirname(__FILE__)) {
Warning: uv_chdir() expects exactly 1 parameter, 0 given in %s on line %d
OK
OK

1
tests/fixtures/poll vendored Normal file
View File

@ -0,0 +1 @@
hoge

2
uv.c
View File

@ -190,7 +190,7 @@ static int php_uv_class_init(TSRMLS_D)
zend_declare_class_constant_long(uv_class_entry, "HTTP_RESPONSE", sizeof("HTTP_RESPONSE")-1, HTTP_RESPONSE TSRMLS_CC);
#endif
#define PHP_UV_ERRNO_GEN(code_notused, name, msg_notused) zend_declare_class_constant_long(uv_class_entry, #name, sizeof(#name)-1, UV_##name TSRMLS_CC);
#define PHP_UV_ERRNO_GEN(name, msg_notused) zend_declare_class_constant_long(uv_class_entry, #name, sizeof(#name)-1, UV_##name TSRMLS_CC);
UV_ERRNO_MAP(PHP_UV_ERRNO_GEN)
#undef PHP_UV_ERRNO_GEN